--- old/src/share/vm/utilities/semaphore.hpp 2015-06-15 21:33:25.864174885 +0200 +++ new/src/share/vm/utilities/semaphore.hpp 2015-06-15 21:33:25.720170048 +0200 @@ -28,39 +28,35 @@ #include "memory/allocation.hpp" #include "utilities/globalDefinitions.hpp" -#define IMPLEMENTS_SEMAPHORE_CLASS 1 - -#if defined(TARGET_OS_FAMILY_bsd) +#if defined(TARGET_OS_FAMILY_linux) || defined(TARGET_OS_FAMILY_solaris) || defined(TARGET_OS_FAMILY_aix) +# include "semaphore_posix.hpp" +#elif defined(TARGET_OS_FAMILY_bsd) # include "semaphore_bsd.hpp" -#elif defined(TARGET_OS_FAMILY_linux) -# include "semaphore_linux.hpp" -#elif defined(TARGET_OS_FAMILY_solaris) -# include "semaphore_solaris.hpp" #elif defined(TARGET_OS_FAMILY_windows) # include "semaphore_windows.hpp" #else - // Redefine for platforms that don't implement the Semaphore class. -# undef IMPLEMENTS_SEMAPHORE_CLASS -# define IMPLEMENTS_SEMAPHORE_CLASS 0 +# error "No semaphore implementation provided for this OS" #endif -#if IMPLEMENTS_SEMAPHORE_CLASS - class Semaphore : public CHeapObj { + private: + // Prevent copying and assignment of Semaphore instances. + Semaphore(const Semaphore &); + Semaphore& operator=(const Semaphore&); + + protected: + os_semaphore_t _semaphore; + public: static const uint NoMaxCount = (uint)-1; Semaphore(uint value = 0, uint max = NoMaxCount); - ~Semaphore(); + virtual ~Semaphore(); + void signal(); void signal(uint count); + void wait(); - bool trywait(); - bool timedwait(unsigned int sec, int nsec); - private: - os_semaphore_t _semaphore; }; -#endif - #endif // SHARE_VM_UTILITIES_SEMAPHORE_HPP