Subj : Predicate for pthread_cond_timedwait() ?? To : comp.programming.threads From : recvfrom@gmail.com Date : Wed Mar 16 2005 05:19 pm Hi! Rather than mess with timers and signals in a threaded app, I tried using pthread_cond_timedwait() for a condvar that will never be signaled. Is this a good approach? It seems to work fine. Also, I assume this call should be wrapped in a loop, since there is no guarantee that the call could return for some 'other' reason (whatever that might be, I'm not sure). What should be the predicate for this loop? A zero return value? E.g.: r = 0; while (r == 0) { r = pthread_cond_timedwait (&x->condvar, &x->mutex, &ts); } This is part of a larger loop in a monitor thread that watches a data structure. Some events can lead to stale entries. This timed polling doesn't happen unless there is actually something in the data structure. Thanks for any advice, tips, hints, etc. -r .