23 int whatsup = th->m_Whatsup;
24 void* data = th->m_AdditionalData;
25 th->m_WhatsupMutex.
unlock();
27 th->
run(whatsup, data);
48 pthread_t *thread =
new pthread_t;
50 m_WhatsupMutex.lock();
52 m_AdditionalData = data;
58 pthread_attr_setdetachstate (&tattr, PTHREAD_CREATE_DETACHED);
62 int t = pthread_create(thread,
NULL, &
_kickoff, (
void*)
this);
68 cout << strerror (errno) << endl;
70 cout <<
"eagain" << endl;
75 pthread_detach (*thread);
119 mutex = (
void*)
new pthread_mutex_t;
121 pthread_mutexattr_t attr;
122 pthread_mutexattr_init(&attr);
123 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
125 pthread_mutex_init((pthread_mutex_t*)mutex, &attr);
126 pthread_mutexattr_destroy(&attr);
128 pthread_mutex_init((pthread_mutex_t*)mutex,
NULL);
134 pthread_mutex_destroy((pthread_mutex_t*) mutex);
135 delete (pthread_mutex_t*)mutex;
140 pthread_mutex_lock( (pthread_mutex_t*) mutex );
145 return pthread_mutex_trylock( (pthread_mutex_t*) mutex ) != EBUSY;
150 pthread_mutex_unlock( (pthread_mutex_t*) mutex );
153 #else // WIN32 defined 157 #include <sys/time.h> 170 mutex = (
void*)CreateEvent(
NULL,FALSE,TRUE,
NULL);
178 CloseHandle((HANDLE)mutex);
185 WaitForSingleObject( (HANDLE)mutex, INFINITE );
191 return WaitForSingleObject( (HANDLE)mutex, 1) != WAIT_TIMEOUT;
199 SetEvent((HANDLE)mutex);
205 int whatsup = th->m_Whatsup;
206 void* data = th->m_AdditionalData;
208 th->m_WhatsupMutex.
unlock();
209 th->
run(whatsup, data);
215 m_WhatsupMutex.lock();
217 m_AdditionalData = data;
219 unsigned long thread = _beginthread(
_kickoff, 0, (
void*)
this);
221 while(m_Whatsup == -1);
223 m_WhatsupMutex.lock();
224 m_WhatsupMutex.unlock();
225 if (thread == (
unsigned long)(-1))
228 cout << strerror (errno) << endl;
230 cout <<
"eagain" << endl;
245 Sleep ((ms+500)/1000);
void * _kickoff(void *ptr)
bool startThread(int whatsup, void *data=NULL)
virtual void run(int whatsup, void *data)=0
vuMutex(bool recursive=false)
static void usleep(unsigned long ms)
sleep for n microseconds (!!not yet implemented for win32)