/** @file common/mutex.cpp Implementace hlavickoveho souboru common/mutex.h @author Petr Wolf */ #include "common/mutex.h" #include "common/exc.h" TMutex::TMutex() { mutex = SDL_CreateMutex(); if ( mutex== NULL ) { THROW(E_8K,"Cannot create the mutex"); } } TMutex::~TMutex() { if (mutex) SDL_DestroyMutex(mutex); mutex = NULL; } int TMutex::lock() { if ( SDL_mutexP(mutex) < 0 ) { THROW(E_8K,"Cannot lock the mutex"); } return 0; } int TMutex::unlock() { if ( SDL_mutexV(mutex) < 0 ) { THROW(E_8K,"Cannot unlock the mutex"); } return 0; }