Hi,

J.P. Delport wrote:
Hi,

Cory Riddell wrote:
I'm using boost::threads, but not any of the timed wait stuff. I run my
viewer in its own thread.

It is my understanding that for a timed wait, you do need to manually
track how much time has actually elapsed

Only if the time specified is a relative time. Pthreads uses an absolute time specifically for this problem. It's easy to restart with an absolute time in future and you don't have to keep track of time passed manually. OT does not have this facility, I'll double check if boost has relative/absolute time.

Looks like boost has both versions now... and even versions that can do the loop to avoid the spurious wakeups automatically...

http://www.boost.org/doc/libs/1_38_0/doc/html/thread/synchronization.html#thread.synchronization.condvar_ref

jp


The only reason I want to use the timed wait is to make sure the users of my app don't deadlock it waiting for a condition. If there is some other way to handle it without the timed wait, I'm interested.

rgds
jp

 > and restart the wait if necessary.


Cory

J.P. Delport wrote:
Hi all,

I'm using OpenThreads in a cross-platform application and wanted to
use the Condition implementation, specifically the wait(timeout)
version. However, the pthread docs suggest that pthread_cond_timedwait
(that is used by OT) can return without explicitly being signalled
(so-called spurious wakeups [1]). Now if I used pthreads directly I
can just put the wait in a while loop checking my condition, because
pthread_cond_timedwait takes an absolute time as a parameter and not a
relative time as OT::Condition does.

With the current OT::Condition there is no way to easily restart the
timed wait (one will have to keep track of time oneself and OT does
not have functions for it).

I've searched for places in OSG where the timed wait is used and it is
not used much. It is used in block(timeout) too, but that is also not
used much in OSG. However, in the new ffmpeg plugin there is also this
comment before using the timed wait:

---8<---
// We don't wait in a loop to avoid an infinite loop (as the ms
timeout would not be decremented).
// This means that timedPop() could return with (is_empty = true)
before the timeout has been hit.
---8<---

Does anyone have more information on how to handle this issue? Should
I just write my code to cope with this limitation? Has anyone used
boost threads (and associated sync utils) with OSG?

rgds
jp


[1] see the pthread docs or
http://en.wikipedia.org/wiki/Spurious_wakeup

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks Transtec Computers for their support.

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to