moved screen mutex from smush into SDL backend (other backends have to make sure they are thread safe by themselves)

svn-id: r7230
This commit is contained in:
Max Horn 2003-04-30 19:11:33 +00:00
parent 7093694781
commit feab6f904f
5 changed files with 30 additions and 17 deletions

View file

@ -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