darwin: merge uv_cond_timedwait implementation

Merge the OS X specific implementation of uv_cond_timedwait() with the
generic one. The only difference is that it now uses mach_absolute_time
instead of gettimeofday.
This commit is contained in:
Ben Noordhuis 2013-02-04 20:12:22 +01:00
parent b271b0686d
commit 8311390f13

View File

@ -323,31 +323,6 @@ void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
abort();
}
#if defined(__APPLE__) && defined(__MACH__)
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
int r;
struct timeval tv;
struct timespec ts;
uint64_t abstime;
gettimeofday(&tv, NULL);
abstime = tv.tv_sec * 1e9 + tv.tv_usec * 1e3 + timeout;
ts.tv_sec = abstime / NANOSEC;
ts.tv_nsec = abstime % NANOSEC;
r = pthread_cond_timedwait(cond, mutex, &ts);
if (r == 0)
return 0;
if (r == ETIMEDOUT)
return -1;
abort();
return -1; /* Satisfy the compiler. */
}
#else /* !(defined(__APPLE__) && defined(__MACH__)) */
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
int r;
@ -369,8 +344,6 @@ int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
return -1; /* Satisfy the compiler. */
}
#endif /* defined(__APPLE__) && defined(__MACH__) */
#if defined(__APPLE__) && defined(__MACH__)