It looks like a dirty hack, it probably is, but this fixes the GC

This commit is contained in:
bart@bartbes.ath.cx
2010-05-20 21:53:50 +02:00
parent a349c9f85a
commit 200d4bc653
3 changed files with 30 additions and 7 deletions
+10
View File
@@ -194,7 +194,15 @@ namespace sdl
delete[] data;
delete comm;
if (handle)
{
bool inGC = (_gcthread == SDL_GetThreadID(handle));
bool collectSelf = (inGC && _gcthread == SDL_ThreadID());
inGC = inGC && !collectSelf;
if (inGC) SDL_mutexP((SDL_mutex *) _gcmutex);
if (collectSelf) SDL_mutexV((SDL_mutex *) _gcmutex);
SDL_KillThread(handle);
if (inGC) SDL_mutexV((SDL_mutex *) _gcmutex);
}
module->unregister(name);
SDL_DestroyMutex(mutex);
SDL_DestroyCond(cond);
@@ -211,8 +219,10 @@ namespace sdl
{
if (handle)
{
SDL_mutexP((SDL_mutex *) _gcmutex);
SDL_KillThread(handle);
handle = 0;
SDL_mutexV((SDL_mutex *) _gcmutex);
}
}