X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fwin32%2FIOManager.c;h=81dedda569874775114bce599334ac720b3662e0;hb=c004ec62b41aa2137b5b5e298ca562609b0de92e;hp=6af42456aef203a80e816d613eadf3f0833fd7e0;hpb=ca8ac445fedf1ef7604ba0b21f2bca0abe461ef8;p=ghc-hetmet.git diff --git a/rts/win32/IOManager.c b/rts/win32/IOManager.c index 6af4245..81dedda 100644 --- a/rts/win32/IOManager.c +++ b/rts/win32/IOManager.c @@ -443,25 +443,29 @@ AddProcRequest ( void* proc, return depositWorkItem(reqID, wItem); } -void ShutdownIOManager ( void ) +void ShutdownIOManager ( rtsBool wait_threads ) { int num; SetEvent(ioMan->hExitEvent); - /* Wait for all worker threads to die. */ - for (;;) { - EnterCriticalSection(&ioMan->manLock); - num = ioMan->numWorkers; - LeaveCriticalSection(&ioMan->manLock); - if (num == 0) - break; - Sleep(10); + if (wait_threads) { + /* Wait for all worker threads to die. */ + for (;;) { + EnterCriticalSection(&ioMan->manLock); + num = ioMan->numWorkers; + LeaveCriticalSection(&ioMan->manLock); + if (num == 0) + break; + Sleep(10); + } + FreeWorkQueue(ioMan->workQueue); + CloseHandle(ioMan->hExitEvent); + DeleteCriticalSection(&ioMan->active_work_lock); + DeleteCriticalSection(&ioMan->manLock); + free(ioMan); + ioMan = NULL; } - FreeWorkQueue(ioMan->workQueue); - CloseHandle(ioMan->hExitEvent); - free(ioMan); - ioMan = NULL; } /* Keep track of WorkItems currently being serviced. */