From ddee2625cb85cd2db5505f56cb2f9f97c4888518 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Sat, 13 Sep 2003 06:55:07 +0000 Subject: [PATCH] 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 --- sc2/src/sc2code/libs/graphics/sdl/dcqueue.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c index 1ff373c08..35c7093a9 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c +++ b/sc2/src/sc2code/libs/graphics/sdl/dcqueue.c @@ -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