Boost logo

Threads-Devel :

From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2006-08-30 09:30:47


Hi,

I'm having problems with thread::sleep() waking up too early. In the pthread
implementation of thread::sleep, the implementation loops using a totally
arbitrary number, i.e.:

for (int foo=0; foo < 5; ++foo)
{
...
}

Is there any specific reason why the loop can't be implemented as e.g.:

do
{
...
}
while (xtime_cmp(xt, cur) > 0);

---------------
The only reason I can think of is the possibility that the system time would
change while inside the loop. Why not use CLOCK_MONOTONIC internally instead
and loop until the time has elapsed? It's perhaps a bit more awkward to
implement, but leads to less surprises to the user, IMHO.

I'm using BOOST_RC_1_34_0, under OpenSuse 10 and gcc 4.0.1.

// Johan


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk