20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_RUNTIME_SEMAPHORE_HPP 26 #define SHARE_VM_RUNTIME_SEMAPHORE_HPP 27 28 #include "memory/allocation.hpp" 29 30 #if defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_solaris) || defined(TARGET_OS_FAMILY_aix) 31 # include "semaphore_posix.hpp" 32 #elif defined(TARGET_OS_FAMILY_bsd) 33 # include "semaphore_bsd.hpp" 34 #elif defined(TARGET_OS_FAMILY_windows) 35 # include "semaphore_windows.hpp" 36 #else 37 # error "No semaphore implementation provided for this OS" 38 #endif 39 40 class Semaphore : public CHeapObj<mtInternal> { 41 private: 42 // Prevent copying and assignment of Semaphore instances. 43 Semaphore(const Semaphore&); 44 Semaphore& operator=(const Semaphore&); 45 46 protected: 47 SemaphoreImpl _impl; 48 49 public: 50 Semaphore(uint value = 0); 51 ~Semaphore(); 52 53 void signal(uint count = 1); 54 55 void wait(); 56 }; 57 58 59 #endif // SHARE_VM_RUNTIME_SEMAPHORE_HPP | 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_RUNTIME_SEMAPHORE_HPP 26 #define SHARE_VM_RUNTIME_SEMAPHORE_HPP 27 28 #include "memory/allocation.hpp" 29 30 #if defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_solaris) || defined(TARGET_OS_FAMILY_aix) 31 # include "semaphore_posix.hpp" 32 #elif defined(TARGET_OS_FAMILY_bsd) 33 # include "semaphore_bsd.hpp" 34 #elif defined(TARGET_OS_FAMILY_windows) 35 # include "semaphore_windows.hpp" 36 #else 37 # error "No semaphore implementation provided for this OS" 38 #endif 39 40 // Implements the limited, platform independent Semaphore API. 41 class Semaphore : public CHeapObj<mtInternal> { 42 private: 43 // Prevent copying and assignment of Semaphore instances. 44 Semaphore(const Semaphore&); 45 Semaphore& operator=(const Semaphore&); 46 47 protected: 48 SemaphoreImpl _impl; 49 50 public: 51 Semaphore(uint value = 0) : _impl(value) {} 52 ~Semaphore() {} 53 54 void signal(uint count = 1) { _impl.signal(count); } 55 56 void wait() { _impl.wait(); } 57 }; 58 59 60 #endif // SHARE_VM_RUNTIME_SEMAPHORE_HPP |