...or at least, I think.
I was using a semaphore to wait for a thread pool to empty, and would find that my program would get some work done and then deadlock. Looking at the stack traces, I could see my master thread waiting on the semaphore, my worker threads waiting inside hx::ExitGCFreeZone, and the garbage collector waiting for all the threads to halt.
Finding the mutex and semaphore implementations, I found this in hxMutex:
void Acquire()
{
hx::EnterGCFreeZone();
mMutex.Lock();
hx::ExitGCFreeZone();
}
...and this in hxSemaphore:
void Acquire() {
#if HX_WINDOWS
WaitForSingleObject(sem, INFINITE);
#elif defined(POSIX_SEMAPHORE)
sem_wait(&sem);
#elif defined(APPLE_SEMAPHORE)
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
#endif
}
That is, no calls to EnterGCFreeZone() and ExitGCFreeZone(). I tried adding them without really knowing what I was doing and now my program runs fine.
...or at least, I think.
I was using a semaphore to wait for a thread pool to empty, and would find that my program would get some work done and then deadlock. Looking at the stack traces, I could see my master thread waiting on the semaphore, my worker threads waiting inside
hx::ExitGCFreeZone, and the garbage collector waiting for all the threads to halt.Finding the mutex and semaphore implementations, I found this in
hxMutex:...and this in
hxSemaphore:That is, no calls to
EnterGCFreeZone()andExitGCFreeZone(). I tried adding them without really knowing what I was doing and now my program runs fine.