// // ############################################################################ // # G A M E.O.N.E - LOW LEVEL LIB V1.0 # // ############################################################################ // Copyright (C) 2001 LEVEL ONE ENTERTAINMENT, // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // Libhome // Contact // //:----------------------------------------------------------------------------- // Modification History: // 03 Sep 2001, Alex Piko -- Generated 23:51:08 by Genitor OCS V4.50.915.2 // //:----------------------------------------------------------------------------- //:Custom #define WIN32_LEAN_AND_MEAN //:End Custom //:ClassInc #include "sys_thread.h" //:Include #include #define SYS_PLATFORM_WIN32_GDI #include //:> +-----------------------------------+ //:>-------------------| Local Function Declarations |-------------------- //:> +-----------------------------------+ //::1 // +----------------+ // | ThreadFunc() | // +----------------+ static DWORD WINAPI ThreadFunc( LPVOID Param); //:> +----------------------------------+ //:>--------------------| Local Function Definitions |-------------------- //:> +----------------------------------+ //::1 // +----------------+ // | ThreadFunc() | // +----------------+ static DWORD WINAPI ThreadFunc( LPVOID Param) { sys_CThread *Thread = (sys_CThread*)Param; SYS_ASSERT_PTR(Thread); DWORD rc = Thread->Main(); delete Thread; return(rc); } //:> +-----------------------------------+ //:>-------------------| Member Function Definitions |-------------------- //:> +-----------------------------------+ //::8 // +---------------+ // | Constructor | // +---------------+ sys_CThread::sys_CThread() { Create(); } //::2 // +--------------+ // | Destructor | // +--------------+ sys_CThread::~sys_CThread() { if(m_hThread) { ::WaitForSingleObject(m_hThread, INFINITE); ::CloseHandle(m_hThread); } } //::6 // +----------+ // | Main() | // +----------+ int sys_CThread::Main() { return 0; } //::4 // +------------+ // | Resume() | // +------------+ void sys_CThread::Resume() { if( m_hThread == 0 ) Create(); ::ResumeThread(m_hThread); } //::3 // +-------------+ // | Suspend() | // +-------------+ void sys_CThread::Suspend() { if(m_hThread) { ::SuspendThread(m_hThread); } } //::5 // +---------------+ // | Terminate() | // +---------------+ void sys_CThread::Terminate() { if(m_hThread) { ::TerminateThread(m_hThread,0); ::CloseHandle(m_hThread); m_hThread = 0; } } // +------------+ // | Create() | // +------------+ void sys_CThread::Create() { DWORD ThreadId; m_hThread = ::CreateThread(NULL, 0, &ThreadFunc, this, CREATE_SUSPENDED, &ThreadId); SYS_ASSERT(m_hThread!=0); }