Do fastpath if timeout is 0 on threadqueue_get

This commit is contained in:
Nils O. Selåsdal
2012-12-09 22:34:25 +01:00
parent f6aad1e77a
commit 1f70f9f4b0
+6 -1
View File
@@ -126,7 +126,12 @@ int uc_thread_queue_get(struct uc_threadqueue *queue, const struct timespec *tim
//another thread popped the remaining elment before we did //another thread popped the remaining elment before we did
queue->num_read_waiters++; queue->num_read_waiters++;
if (timeout) { if (timeout) {
rc = pthread_cond_timedwait(&queue->read_cond, &queue->mutex, &abstimeout); //fastpath, check for a poll
if(timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
rc = ETIMEDOUT;
} else {
rc = pthread_cond_timedwait(&queue->read_cond, &queue->mutex, &abstimeout);
}
} else { } else {
pthread_cond_wait(&queue->read_cond, &queue->mutex); pthread_cond_wait(&queue->read_cond, &queue->mutex);