8#include <dispatch/dispatch.h>
39 dispatch_time_t timeout =
40 dispatch_time(DISPATCH_TIME_NOW, rel_time.InNanoseconds());
66 FATAL(
"Error when signaling semaphore, errno: %d", errno);
90 if (
result == 0)
return true;
91#if V8_LIBC_GLIBC && !V8_GLIBC_PREREQ(2, 4)
98 if (
result == -1 && errno == ETIMEDOUT) {
112 native_handle_ = ::CreateSemaphoreA(
nullptr, count, 0x7FFFFFFF,
nullptr);
140 TimeTicks
end = now + rel_time;
142 int64_t msec = (
end - now).InMilliseconds();
143 if (msec >=
static_cast<int64_t
>(INFINITE)) {
145 if (
result == WAIT_OBJECT_0) {
153 if (
result == WAIT_TIMEOUT) {
166Semaphore::~Semaphore() {}
168void Semaphore::Signal() { native_handle_.Put(); }
170void Semaphore::Wait() { native_handle_.Take(); }
172bool Semaphore::WaitFor(
const TimeDelta& rel_time) {
173 int64_t microseconds = rel_time.InMicroseconds();
174 return native_handle_.TakeWait(microseconds);
NativeHandle native_handle_
bool WaitFor(const TimeDelta &rel_time) V8_WARN_UNUSED_RESULT
static Time NowFromSystemTime()
struct timespec ToTimespec() const
ZoneVector< RpoNumber > & result
#define DCHECK_NOT_NULL(val)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)