git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3665 0c269be4-1314-0410-8aa9-9f06e86f4224tags/v1.9.4
| @@ -33,6 +33,47 @@ namespace Jack | |||||
| \brief Mutex abstraction. | \brief Mutex abstraction. | ||||
| */ | */ | ||||
| class JackBasePosixMutex | |||||
| { | |||||
| protected: | |||||
| pthread_mutex_t fMutex; | |||||
| public: | |||||
| JackBasePosixMutex() | |||||
| { | |||||
| pthread_mutex_init(&fMutex, NULL); | |||||
| } | |||||
| virtual ~JackBasePosixMutex() | |||||
| { | |||||
| pthread_mutex_destroy(&fMutex); | |||||
| } | |||||
| void Lock() | |||||
| { | |||||
| int res = pthread_mutex_lock(&fMutex); | |||||
| if (res != 0) | |||||
| jack_error("JackBasePosixMutex::Lock res = %d", res); | |||||
| } | |||||
| bool Trylock() | |||||
| { | |||||
| return (pthread_mutex_trylock(&fMutex) == 0); | |||||
| } | |||||
| void Unlock() | |||||
| { | |||||
| int res = pthread_mutex_unlock(&fMutex); | |||||
| if (res != 0) | |||||
| jack_error("JackBasePosixMutex::Unlock res = %d", res); | |||||
| } | |||||
| }; | |||||
| class JackPosixMutex | class JackPosixMutex | ||||
| { | { | ||||
| @@ -32,7 +32,7 @@ namespace Jack | |||||
| \brief A synchronization primitive built using a condition variable. | \brief A synchronization primitive built using a condition variable. | ||||
| */ | */ | ||||
| class JackProcessSync : public JackPosixMutex | |||||
| class JackProcessSync : public JackBasePosixMutex | |||||
| { | { | ||||
| private: | private: | ||||
| @@ -41,12 +41,12 @@ class JackProcessSync : public JackPosixMutex | |||||
| public: | public: | ||||
| JackProcessSync():JackPosixMutex() | |||||
| JackProcessSync():JackBasePosixMutex() | |||||
| { | { | ||||
| pthread_cond_init(&fCond, NULL); | pthread_cond_init(&fCond, NULL); | ||||
| } | } | ||||
| ~JackProcessSync() | |||||
| virtual ~JackProcessSync() | |||||
| { | { | ||||
| pthread_cond_destroy(&fCond); | pthread_cond_destroy(&fCond); | ||||
| } | } | ||||