Remove threading from miniwin
This commit is contained in:
parent
5526140672
commit
c26fa8fa3f
19 changed files with 151 additions and 281 deletions
|
|
@ -4,13 +4,13 @@
|
|||
DEVILUTION_BEGIN_NAMESPACE
|
||||
|
||||
static CCritSect sgMemCrit;
|
||||
unsigned int glpDThreadId;
|
||||
SDL_threadID glpDThreadId;
|
||||
TMegaPkt *sgpInfoHead; /* may not be right struct */
|
||||
BOOLEAN dthread_running;
|
||||
HANDLE sghWorkToDoEvent;
|
||||
event_emul *sghWorkToDoEvent;
|
||||
|
||||
/* rdata */
|
||||
static HANDLE sghThread = INVALID_HANDLE_VALUE;
|
||||
static SDL_Thread *sghThread = NULL;
|
||||
|
||||
void dthread_remove_player(int pnum)
|
||||
{
|
||||
|
|
@ -58,7 +58,7 @@ void dthread_start()
|
|||
return;
|
||||
}
|
||||
|
||||
sghWorkToDoEvent = CreateEvent();
|
||||
sghWorkToDoEvent = StartEvent();
|
||||
if (!sghWorkToDoEvent) {
|
||||
error_buf = TraceLastError();
|
||||
app_fatal("dthread:1\n%s", error_buf);
|
||||
|
|
@ -66,8 +66,8 @@ void dthread_start()
|
|||
|
||||
dthread_running = TRUE;
|
||||
|
||||
sghThread = (HANDLE)_beginthreadex(NULL, 0, dthread_handler, NULL, 0, &glpDThreadId);
|
||||
if (sghThread == INVALID_HANDLE_VALUE) {
|
||||
sghThread = CreateThread(dthread_handler, &glpDThreadId);
|
||||
if (sghThread == NULL) {
|
||||
error_buf = TraceLastError();
|
||||
app_fatal("dthread2:\n%s", error_buf);
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ unsigned int dthread_handler(void *)
|
|||
DWORD dwMilliseconds;
|
||||
|
||||
while (dthread_running) {
|
||||
if (!sgpInfoHead && WaitForSingleObject(sghWorkToDoEvent, 0xFFFFFFFF) == -1) {
|
||||
if (!sgpInfoHead && WaitForEvent(sghWorkToDoEvent) == -1) {
|
||||
error_buf = TraceLastError();
|
||||
app_fatal("dthread4:\n%s", error_buf);
|
||||
}
|
||||
|
|
@ -122,15 +122,11 @@ void dthread_cleanup()
|
|||
|
||||
dthread_running = FALSE;
|
||||
SetEvent(sghWorkToDoEvent);
|
||||
if (sghThread != INVALID_HANDLE_VALUE && glpDThreadId != GetCurrentThreadId()) {
|
||||
if (WaitForSingleObject(sghThread, 0xFFFFFFFF) == -1) {
|
||||
error_buf = TraceLastError();
|
||||
app_fatal("dthread3:\n(%s)", error_buf);
|
||||
}
|
||||
CloseEvent(sghThread);
|
||||
sghThread = INVALID_HANDLE_VALUE;
|
||||
if (sghThread != NULL && glpDThreadId != SDL_GetThreadID(NULL)) {
|
||||
SDL_WaitThread(sghThread, NULL);
|
||||
sghThread = NULL;
|
||||
}
|
||||
CloseEvent(sghWorkToDoEvent);
|
||||
EndEvent(sghWorkToDoEvent);
|
||||
sghWorkToDoEvent = NULL;
|
||||
|
||||
while (sgpInfoHead) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue