31 #include <mach/mach_init.h>
32 #include <mach/task.h>
45 Semaphore::Semaphore(
int count) {
46 kern_return_t result = semaphore_create(
47 mach_task_self(), &native_handle_, SYNC_POLICY_FIFO, count);
53 Semaphore::~Semaphore() {
54 kern_return_t result = semaphore_destroy(mach_task_self(), native_handle_);
61 kern_return_t result = semaphore_signal(native_handle_);
67 void Semaphore::Wait() {
69 kern_return_t result = semaphore_wait(native_handle_);
70 if (result == KERN_SUCCESS)
return;
76 bool Semaphore::WaitFor(
const TimeDelta& rel_time) {
77 TimeTicks now = TimeTicks::Now();
78 TimeTicks end = now + rel_time;
86 ts = (end - now).ToMachTimespec();
88 kern_return_t result = semaphore_timedwait(native_handle_, ts);
89 if (result == KERN_SUCCESS)
return true;
90 if (result == KERN_OPERATION_TIMED_OUT)
return false;
92 now = TimeTicks::Now();
98 Semaphore::Semaphore(
int count) {
100 int result = sem_init(&native_handle_, 0, count);
106 Semaphore::~Semaphore() {
107 int result = sem_destroy(&native_handle_);
114 int result = sem_post(&native_handle_);
120 void Semaphore::Wait() {
122 int result = sem_wait(&native_handle_);
123 if (result == 0)
return;
131 bool Semaphore::WaitFor(
const TimeDelta& rel_time) {
133 const Time time = Time::NowFromSystemTime() + rel_time;
134 const struct timespec ts = time.ToTimespec();
138 int result = sem_timedwait(&native_handle_, &ts);
139 if (result == 0)
return true;
140 #if V8_LIBC_GLIBC && !V8_GLIBC_PREREQ(2, 4)
147 if (result == -1 && errno == ETIMEDOUT) {
159 Semaphore::Semaphore(
int count) {
161 native_handle_ = ::CreateSemaphoreA(
NULL, count, 0x7fffffff,
NULL);
166 Semaphore::~Semaphore() {
167 BOOL result = CloseHandle(native_handle_);
175 BOOL result = ReleaseSemaphore(native_handle_, 1, &dummy);
181 void Semaphore::Wait() {
182 DWORD result = WaitForSingleObject(native_handle_, INFINITE);
183 ASSERT(result == WAIT_OBJECT_0);
188 bool Semaphore::WaitFor(
const TimeDelta& rel_time) {
189 TimeTicks now = TimeTicks::Now();
190 TimeTicks end = now + rel_time;
192 int64_t msec = (end - now).InMilliseconds();
193 if (msec >= static_cast<int64_t>(INFINITE)) {
194 DWORD result = WaitForSingleObject(native_handle_, INFINITE - 1);
195 if (result == WAIT_OBJECT_0) {
198 ASSERT(result == WAIT_TIMEOUT);
199 now = TimeTicks::Now();
201 DWORD result = WaitForSingleObject(
202 native_handle_, (msec < 0) ? 0 : static_cast<DWORD>(msec));
203 if (result == WAIT_TIMEOUT) {
206 ASSERT(result == WAIT_OBJECT_0);
212 #endif // V8_OS_MACOSX
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void Signal(const v8::FunctionCallbackInfo< v8::Value > &args)
#define ASSERT(condition)
typedef DWORD(__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID)
typedef BOOL(__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess
#define ASSERT_EQ(v1, v2)