12 #include "../stdafx.h" 19 #include "../safeguards.h" 39 self_destruct(self_destruct)
41 thread = _beginthread(
stThreadProc, NULL, 1048576,
this);
52 DosWaitThread(&this->thread, DCWW_WAIT);
73 this->
proc(this->param);
89 if (thread != NULL) *thread = to;
105 DosCreateMutexSem(NULL, &mutex, 0, FALSE);
106 DosCreateEventSem(NULL, &event, 0, FALSE);
111 DosCloseMutexSem(mutex);
112 DosCloseEventSem(event);
118 DosRequestMutexSem(mutex, (
unsigned long) SEM_INDEFINITE_WAIT);
119 this->recursive_count++;
120 if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
125 if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
126 this->recursive_count--;
127 DosReleaseMutexSem(mutex);
132 assert(this->recursive_count == 1);
134 DosWaitEventSem(event, SEM_INDEFINITE_WAIT);
135 this->BeginCritical();
140 DosPostEventSem(event);
void BeginCritical(bool allow_recursive=false)
Begin the critical section.
void EndCritical(bool allow_recursive=false)
End of the critical section.
static void stThreadProc(void *thr)
On thread creation, this function is called, which calls the real startup function.
void(* OTTDThreadFunc)(void *)
Definition of all thread entry functions.
void * param
Parameter for the external thread procedure.
bool Exit()
Exit this thread.
bool self_destruct
Free ourselves when done?
TID thread
System thread identifier.
void ThreadProc()
A new thread is created, and this function is called.
OTTDThreadFunc proc
External thread procedure.
OS/2 version of ThreadMutex.
static ThreadMutex * New()
Create a new mutex.
HEV event
Event for waiting.
ThreadObject_OS2(OTTDThreadFunc proc, void *param, bool self_destruct)
Create a thread and start it, calling proc(param).
OS/2 version for ThreadObject.
void Join()
Join this thread.
void WaitForSignal()
Wait for a signal to be send.
uint recursive_count
Recursive lock count.
void SendSignal()
Send a signal and wake the 'thread' that was waiting for it.
A Thread Object which works on all our supported OSes.
Signal used for signalling we knowingly want to end the thread.
static bool New(OTTDThreadFunc proc, void *param, ThreadObject **thread=NULL, const char *name=NULL)
Create a thread; proc will be called as first function inside the thread, with optional params...