diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-10-03 16:26:24 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-10-03 16:26:24 +0200 |
commit | bb65f0fc2176b2ebf0f1be682008609e8bd2cb0a (patch) | |
tree | d0070ad2ef70b1a7c2ed77cec098d03402d0871f /src/osc_graphics.h | |
parent | 920067622e7ba72dd6947eb8e7875719315872b9 (diff) | |
download | osc-graphics-bb65f0fc2176b2ebf0f1be682008609e8bd2cb0a.tar.gz |
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
Diffstat (limited to 'src/osc_graphics.h')
-rw-r--r-- | src/osc_graphics.h | 23 |
1 files changed, 23 insertions, 0 deletions
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 <stdio.h> #include <SDL.h> +#include <SDL_thread.h> + +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" |