Vault
4.1
|
00001 /* 00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved. 00003 This file is part of the Code Vault version 4.1 00004 http://www.bombaydigital.com/ 00005 License: MIT. See LICENSE.md in the Vault top level directory. 00006 */ 00007 00008 #ifndef vsemaphore_h 00009 #define vsemaphore_h 00010 00013 #include "vthread.h" 00014 00015 class VMutex; 00016 00031 class VSemaphore { 00032 public: 00033 00037 VSemaphore(); 00041 virtual ~VSemaphore(); 00042 00050 void wait(VMutex* ownedMutex, const VDuration& timeoutInterval); 00056 void signal(); 00057 00058 /* PLATFORM-SPECIFIC STATIC FUNCTIONS -------------------------------- 00059 The remaining functions defined here are the low-level interfaces to 00060 the platform-specific semaphore APIs. These are implemented in each 00061 platform-specific version of vthread_platform.cpp. 00062 */ 00063 00070 static bool semaphoreInit(VSemaphore_Type* semaphore); 00071 00078 static bool semaphoreDestroy(VSemaphore_Type* semaphore); 00079 00091 static bool semaphoreWait(VSemaphore_Type* semaphore, VMutex_Type* mutex, const VDuration& timeoutInterval); 00092 00099 static bool semaphoreSignal(VSemaphore_Type* semaphore); 00100 00108 static bool semaphoreBroadcast(VSemaphore_Type* semaphore); 00109 00110 private: 00111 00112 VSemaphore_Type mSemaphore; 00113 }; 00114 00115 #endif /* vsemaphore_h */ 00116