< prev index next >

src/os/posix/vm/os_posix.cpp

Print this page

        

*** 1048,1069 **** } } void PosixSemaphore::wait() { int ret; ! while ((ret = sem_wait(&_semaphore)) == -1 && errno == EINTR) { ! // Retry if the wait was interrupted by a signal. ! } assert_with_errno(ret == 0, "sem_wait failed"); } bool PosixSemaphore::trywait() { ! bool succeeded = sem_trywait(&_semaphore) == 0; ! assert_with_errno(succeeded || errno == EAGAIN, "trywait failed"); ! return succeeded; } bool PosixSemaphore::timedwait(const struct timespec ts) { while (true) { int result = sem_timedwait(&_semaphore, &ts); --- 1048,1075 ---- } } 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(const struct timespec ts) { while (true) { int result = sem_timedwait(&_semaphore, &ts);
< prev index next >