From 1f70f9f4b0160968715b0c3920e4189225281476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sun, 9 Dec 2012 22:34:25 +0100 Subject: [PATCH] Do fastpath if timeout is 0 on threadqueue_get --- src/ucore_threadqueue.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ucore_threadqueue.c b/src/ucore_threadqueue.c index df0f4f1..0f23afd 100644 --- a/src/ucore_threadqueue.c +++ b/src/ucore_threadqueue.c @@ -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 queue->num_read_waiters++; 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 { pthread_cond_wait(&queue->read_cond, &queue->mutex);