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 22class BLooper; 23 24class TLockLooperInfo 25{ 26 public: 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 34 void LockTest() { acquire_sem(fTestLock); } 35 void UnlockTest() { release_sem(fTestLock); } 36 void LockThread() { acquire_sem(fThreadLock); } 37 void UnlockThread() { release_sem(fThreadLock); } 38 void UnlockLooper() { fLooper->Unlock(); } 39 void LockLooper() 40 { 41 fLooper->Lock(); 42 } 43 44 private: 45 BLooper* fLooper; 46 sem_id fTestLock; 47 sem_id fThreadLock; 48}; 49 50int32 LockLooperThreadFunc(void* data); 51 52#endif //LOCKLOOPERTESTCOMMON_H 53 54/* 55 * $Log $ 56 * 57 * $Id $ 58 * 59 */ 60 61