|
@@ -38,19 +38,19 @@ public:
|
|
|
param(param),
|
|
|
self_destruct(self_destruct)
|
|
|
{
|
|
|
thread = _beginthread(stThreadProc, NULL, 1048576, this);
|
|
|
}
|
|
|
|
|
|
/* virtual */ bool Exit()
|
|
|
bool Exit() override
|
|
|
{
|
|
|
_endthread();
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
/* virtual */ void Join()
|
|
|
void Join() override
|
|
|
{
|
|
|
DosWaitThread(&this->thread, DCWW_WAIT);
|
|
|
this->thread = 0;
|
|
|
}
|
|
|
private:
|
|
|
/**
|
|
@@ -103,42 +103,42 @@ public:
|
|
|
ThreadMutex_OS2() : recursive_count(0)
|
|
|
{
|
|
|
DosCreateMutexSem(NULL, &mutex, 0, FALSE);
|
|
|
DosCreateEventSem(NULL, &event, 0, FALSE);
|
|
|
}
|
|
|
|
|
|
/* virtual */ ~ThreadMutex_OS2()
|
|
|
~ThreadMutex_OS2() override
|
|
|
{
|
|
|
DosCloseMutexSem(mutex);
|
|
|
DosCloseEventSem(event);
|
|
|
}
|
|
|
|
|
|
/* virtual */ void BeginCritical(bool allow_recursive = false)
|
|
|
void BeginCritical(bool allow_recursive = false) override
|
|
|
{
|
|
|
/* os2 mutex is recursive by itself */
|
|
|
DosRequestMutexSem(mutex, (unsigned long) SEM_INDEFINITE_WAIT);
|
|
|
this->recursive_count++;
|
|
|
if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
|
|
|
}
|
|
|
|
|
|
/* virtual */ void EndCritical(bool allow_recursive = false)
|
|
|
void EndCritical(bool allow_recursive = false) override
|
|
|
{
|
|
|
if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
|
|
|
this->recursive_count--;
|
|
|
DosReleaseMutexSem(mutex);
|
|
|
}
|
|
|
|
|
|
/* virtual */ void WaitForSignal()
|
|
|
void WaitForSignal() override
|
|
|
{
|
|
|
assert(this->recursive_count == 1); // Do we need to call Begin/EndCritical multiple times otherwise?
|
|
|
this->EndCritical();
|
|
|
DosWaitEventSem(event, SEM_INDEFINITE_WAIT);
|
|
|
this->BeginCritical();
|
|
|
}
|
|
|
|
|
|
/* virtual */ void SendSignal()
|
|
|
void SendSignal() override
|
|
|
{
|
|
|
DosPostEventSem(event);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/* static */ ThreadMutex *ThreadMutex::New()
|