From bb65f0fc2176b2ebf0f1be682008609e8bd2cb0a Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 3 Oct 2012 16:26:24 +0200 Subject: simplified mutex locking idiom by introducing Mutex class (wrapper around SDL_mutex) * can be instantiated * can derive from class Mutex to inherit the lock()/unlock() methods also fixed LayerList destructor --- src/osc_graphics.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/osc_graphics.h') diff --git a/src/osc_graphics.h b/src/osc_graphics.h index c36ef54..47afa7d 100644 --- a/src/osc_graphics.h +++ b/src/osc_graphics.h @@ -4,6 +4,29 @@ #include #include +#include + +class Mutex { + SDL_mutex *mutex; + +public: + Mutex() : mutex(SDL_CreateMutex()) {} + virtual ~Mutex() + { + SDL_DestroyMutex(mutex); + } + + inline void + lock() + { + SDL_LockMutex(mutex); + } + inline void + unlock() + { + SDL_UnlockMutex(mutex); + } +}; #include "osc_server.h" #include "layer.h" -- cgit v1.2.3