DCQ synchronization handled with Mutexes now

This may help bug #359.  (Using a Mutex is safe, because checks were
already in place to ensure that only the thread that locked the DCQ can
ever unlock it.)


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1224 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2003-09-13 06:55:07 +00:00
parent e71c28744c
commit ddee2625cb
+6 -6
View File
@@ -24,7 +24,7 @@
#include "libs/graphics/drawcmd.h"
#include "libs/graphics/sdl/dcqueue.h"
Semaphore DCQ_sem;
static Mutex DCQ_lock;
// variables for making the DCQ lock re-entrant
static int DCQ_locking_depth = 0;
@@ -44,11 +44,11 @@ _lock (void)
Uint32 current_thread = SDL_ThreadID ();
if (DCQ_locking_thread != current_thread)
{
SetSemaphore (DCQ_sem);
LockMutex (DCQ_lock);
DCQ_locking_thread = current_thread;
}
++DCQ_locking_depth;
// fprintf (stderr, "DCQ_sem locking depth: %i\n", DCQ_locking_depth);
// fprintf (stderr, "DCQ_lock locking depth: %i\n", DCQ_locking_depth);
}
// Wait for the queue to be emptied.
@@ -90,11 +90,11 @@ Unlock_DCQ (void)
else
{
--DCQ_locking_depth;
// fprintf (stderr, "DCQ_sem locking depth: %i\n", DCQ_locking_depth);
// fprintf (stderr, "DCQ_lock locking depth: %i\n", DCQ_locking_depth);
if (!DCQ_locking_depth)
{
DCQ_locking_thread = 0;
ClearSemaphore (DCQ_sem);
UnlockMutex (DCQ_lock);
}
}
}
@@ -167,7 +167,7 @@ TFB_DrawCommandQueue_Create()
DCQ_locking_depth = 0;
DCQ_locking_thread = 0;
DCQ_sem = CreateSemaphore(1, "DCQ");
DCQ_lock = CreateMutex ();
}
void