diff options
author | Max Horn | 2003-04-30 19:11:33 +0000 |
---|---|---|
committer | Max Horn | 2003-04-30 19:11:33 +0000 |
commit | feab6f904f81e5f6a1fbaf8b1b3b8686242ed00b (patch) | |
tree | db386448d255e93d18ce5751bb94b65c6ed44726 /backends/sdl/sdl-common.h | |
parent | 70936947815df45899879fa0467c6489cc0d72c9 (diff) | |
download | scummvm-rg350-feab6f904f81e5f6a1fbaf8b1b3b8686242ed00b.tar.gz scummvm-rg350-feab6f904f81e5f6a1fbaf8b1b3b8686242ed00b.tar.bz2 scummvm-rg350-feab6f904f81e5f6a1fbaf8b1b3b8686242ed00b.zip |
moved screen mutex from smush into SDL backend (other backends have to make sure they are thread safe by themselves)
svn-id: r7230
Diffstat (limited to 'backends/sdl/sdl-common.h')
-rw-r--r-- | backends/sdl/sdl-common.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index 920e396e79..ca90335a4a 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -200,6 +200,10 @@ protected: // Palette data SDL_Color *_currentPalette; uint _paletteDirtyStart, _paletteDirtyEnd; + + // Mutex that prevents multiple threads interferring with each other + // when accessing the screen. + SDL_mutex *_mutex; void add_dirty_rgn_auto(const byte *buf); @@ -222,5 +226,15 @@ protected: static OSystem_SDL_Common *create(); }; +// Auxillary class to (un)lock a mutex on the stack +class StackLock { + SDL_mutex *_mutex; +public: + StackLock(SDL_mutex *mutex) : _mutex(mutex) { lock(); } + ~StackLock() { unlock(); } + void lock() { SDL_mutexP(_mutex); } + void unlock() { SDL_mutexV(_mutex); } +}; + #endif |