//////////////////////////////////////////////////////////////////////////// // CMutex クラスのインプリメンテーション // //////////////////////////////////////////////////////////////////////////// #include #include #include "Mutex.h" //////////////////////////////////////////////////////////////////////////// // 構築/破棄 //////////////////////////////////////////////////////////////////////////// CMutex::CMutex() { } CMutex::~CMutex() { } //////////////////////////////////////////////////////////////////////////// // メソッド //////////////////////////////////////////////////////////////////////////// // 初期化 bool CMutex::Initialize() { assert( NULL != this ); return pthread_mutex_init( &mutex, NULL ) == 0 ? true : false; } // 破棄 bool CMutex::Destroy() { assert( NULL != this ); return pthread_mutex_destroy( &mutex ) == 0 ? true : false; } // 占有する bool CMutex::Lock() { assert( NULL != this ); return pthread_mutex_lock( &mutex ) == 0 ? true : false; } // 占有を試みる bool CMutex::TryLock() { assert( NULL != this ); return pthread_mutex_trylock( &mutex ) == 0 ? true : false; } // 解放する bool CMutex::Unlock() { assert( NULL != this ); return pthread_mutex_unlock( &mutex ) == 0 ? true : false; }