00001 /* 00002 $Id: thread_beos.cpp,v 1.1 2000/07/18 17:04:27 sphair Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00015 #include "Core/precomp.h" 00016 00017 #include "API/Core/System/cl_assert.h" 00018 #include "thread_beos.h" 00019 00020 CL_Thread *CL_Thread::create(CL_Runnable *runnable) 00021 { 00022 return new CL_Thread_BeOS(runnable); 00023 } 00024 00025 CL_Thread_BeOS::CL_Thread_BeOS(CL_Runnable *runnable) 00026 { 00027 this->runnable = runnable; 00028 running = false; 00029 } 00030 00031 CL_Thread_BeOS::~CL_Thread_BeOS() 00032 { 00033 terminate(); 00034 } 00035 00036 void CL_Thread_BeOS::start() 00037 { 00038 if (running) return; 00039 00040 // cl_assert(pthread_create(&thread, NULL, run_init, this)==0); 00041 00042 running = true; 00043 } 00044 00045 void *CL_Thread_BeOS::run_init(void *_self) 00046 { 00047 CL_Thread_BeOS *self = (CL_Thread_BeOS *) _self; 00048 00049 // kill thread immidiately - no cancelation point... 00050 // pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); 00051 00052 self->runnable->run(); 00053 return NULL; 00054 } 00055 00056 void CL_Thread_BeOS::terminate() 00057 { 00058 // if (running) pthread_cancel(thread); 00059 running = false; 00060 } 00061 00062 void CL_Thread_BeOS::wait() 00063 { 00064 // if (running) pthread_join(thread, NULL); 00065 running = false; 00066 }
1.2.6 written by Dimitri van Heesch,
© 1997-2001