< prev index next >

src/hotspot/os/posix/os_posix.cpp

Print this page

        

*** 29,46 **** #include "runtime/os.hpp" #include "utilities/align.hpp" #include "utilities/macros.hpp" #include "utilities/vmError.hpp" - #ifndef __APPLE__ - // POSIX unamed semaphores are not supported on OS X. - #include "semaphore_posix.hpp" - #endif - #include <dlfcn.h> #include <pthread.h> - #include <semaphore.h> #include <signal.h> #include <sys/mman.h> #include <sys/resource.h> #include <sys/utsname.h> #include <time.h> --- 29,40 ----
*** 1497,1567 **** _crash_protection->restore(); } } } - // POSIX unamed semaphores are not supported on OS X. - #ifndef __APPLE__ - - PosixSemaphore::PosixSemaphore(uint value) { - int ret = sem_init(&_semaphore, 0, value); - - guarantee_with_errno(ret == 0, "Failed to initialize semaphore"); - } - - PosixSemaphore::~PosixSemaphore() { - sem_destroy(&_semaphore); - } - - void PosixSemaphore::signal(uint count) { - for (uint i = 0; i < count; i++) { - int ret = sem_post(&_semaphore); - - assert_with_errno(ret == 0, "sem_post failed"); - } - } - - void PosixSemaphore::wait() { - int ret; - - do { - ret = sem_wait(&_semaphore); - } while (ret != 0 && errno == EINTR); - - assert_with_errno(ret == 0, "sem_wait failed"); - } - - bool PosixSemaphore::trywait() { - int ret; - - do { - ret = sem_trywait(&_semaphore); - } while (ret != 0 && errno == EINTR); - - assert_with_errno(ret == 0 || errno == EAGAIN, "trywait failed"); - - return ret == 0; - } - - bool PosixSemaphore::timedwait(struct timespec ts) { - while (true) { - int result = sem_timedwait(&_semaphore, &ts); - if (result == 0) { - return true; - } else if (errno == EINTR) { - continue; - } else if (errno == ETIMEDOUT) { - return false; - } else { - assert_with_errno(false, "timedwait failed"); - return false; - } - } - } - - #endif // __APPLE__ - // Shared pthread_mutex/cond based PlatformEvent implementation. // Not currently usable by Solaris. #ifndef SOLARIS --- 1491,1500 ----
< prev index next >