1 //------------------------------------------------------------------------------ 2 // LockLooperTestCommon.h 3 // 4 //------------------------------------------------------------------------------ 5 6 #ifndef LOCKLOOPERTESTCOMMON_H 7 #define LOCKLOOPERTESTCOMMON_H 8 9 // Standard Includes ----------------------------------------------------------- 10 11 // System Includes ------------------------------------------------------------- 12 #include <OS.h> 13 14 // Project Includes ------------------------------------------------------------ 15 16 // Local Includes -------------------------------------------------------------- 17 18 // Local Defines --------------------------------------------------------------- 19 20 // Globals --------------------------------------------------------------------- 21 22 class BLooper; 23 24 class TLockLooperInfo 25 { 26 public: TLockLooperInfo(BLooper * Looper)27 TLockLooperInfo(BLooper* Looper) : fLooper(Looper) 28 { 29 // Create it "acquired" 30 fThreadLock = create_sem(0, NULL); 31 fTestLock = create_sem(0, NULL); 32 } 33 LockTest()34 void LockTest() { acquire_sem(fTestLock); } UnlockTest()35 void UnlockTest() { release_sem(fTestLock); } LockThread()36 void LockThread() { acquire_sem(fThreadLock); } UnlockThread()37 void UnlockThread() { release_sem(fThreadLock); } UnlockLooper()38 void UnlockLooper() { fLooper->Unlock(); } LockLooper()39 void LockLooper() 40 { 41 fLooper->Lock(); 42 } 43 44 private: 45 BLooper* fLooper; 46 sem_id fTestLock; 47 sem_id fThreadLock; 48 }; 49 50 int32 LockLooperThreadFunc(void* data); 51 52 #endif //LOCKLOOPERTESTCOMMON_H 53 54 /* 55 * $Log $ 56 * 57 * $Id $ 58 * 59 */ 60 61