mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Remove WinRun hack from hsThread
This commit is contained in:
@ -102,10 +102,6 @@ public:
|
||||
static void* Alloc(size_t size); // does not call operator::new(), may return nil
|
||||
static void Free(void* p); // does not call operator::delete()
|
||||
static void ThreadYield();
|
||||
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
DWORD WinRun();
|
||||
#endif
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -46,16 +46,23 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsExceptions.h"
|
||||
#include "hsMemory.h"
|
||||
|
||||
// typedef unsigned int __stdcall (*EntryPtCB)(void*);
|
||||
|
||||
static DWORD __stdcall gEntryPoint(void* param)
|
||||
struct WinThreadParam
|
||||
{
|
||||
return ((hsThread*)param)->WinRun();
|
||||
}
|
||||
hsThread* fThread;
|
||||
HANDLE fQuitSemaH; // private member of hsThread
|
||||
|
||||
WinThreadParam(hsThread* t, HANDLE quit)
|
||||
: fThread(t), fQuitSemaH(quit)
|
||||
{ }
|
||||
};
|
||||
|
||||
static unsigned int __stdcall gEntryPointBT(void* param)
|
||||
{
|
||||
return ((hsThread*)param)->WinRun();
|
||||
WinThreadParam* wtp = (WinThreadParam*)param;
|
||||
unsigned int result = wtp->fThread->Run();
|
||||
::ReleaseSemaphore(wtp->fQuitSemaH, 1, nil); // signal that we've quit
|
||||
delete param;
|
||||
return result;
|
||||
}
|
||||
|
||||
hsThread::hsThread(uint32_t stackSize) : fStackSize(stackSize), fQuit(false), fThreadH(nil), fQuitSemaH(nil)
|
||||
@ -74,12 +81,8 @@ void hsThread::Start()
|
||||
fQuitSemaH = ::CreateSemaphore(nil, 0, kPosInfinity32, nil);
|
||||
if (fQuitSemaH == nil)
|
||||
throw hsOSException(-1);
|
||||
|
||||
#if 0
|
||||
fThreadH = ::CreateThread(nil, fStackSize, gEntryPoint, this, 0, &fThreadId);
|
||||
#else
|
||||
fThreadH = (HANDLE)_beginthreadex(nil, fStackSize, gEntryPointBT, this, 0, (unsigned int*)&fThreadId);
|
||||
#endif
|
||||
WinThreadParam* wtp = new WinThreadParam(this, fQuitSemaH);
|
||||
fThreadH = (HANDLE)_beginthreadex(nil, fStackSize, gEntryPointBT, wtp, 0, (unsigned int*)&fThreadId);
|
||||
if (fThreadH == nil)
|
||||
throw hsOSException(-1);
|
||||
}
|
||||
@ -100,15 +103,6 @@ void hsThread::Stop()
|
||||
}
|
||||
}
|
||||
|
||||
DWORD hsThread::WinRun()
|
||||
{
|
||||
DWORD result = this->Run();
|
||||
|
||||
::ReleaseSemaphore(fQuitSemaH, 1, nil); // signal that we've quit
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void* hsThread::Alloc(size_t size)
|
||||
|
Reference in New Issue
Block a user