Boost logo

Boost :

From: Magomed Abdurakhmanov (maq_at_[hidden])
Date: 2004-04-15 19:18:57

Hello. I have some troubles with boost::thread, and think they are important:

1. condition::timed_wait dangerous to use, because waiting delay specified as time
when we are will stop waiting. So this is very surprising when system time is changed!
I guess that waiting for specified delay is much more safe than waiting until some time arrive.

For example try launch the program bellow and change system time backward (to past) when it's working.
I have tested this under win32 + msvc7
// -------------------------------
boost::condition cvar;
boost::mutex monitor;

void thread1()
                boost::mutex::scoped_lock lock(monitor);

                boost::xtime xt;
        boost::xtime_get(&xt, boost::TIME_UTC);
                std::cout << "now: " << xt.sec << std::endl;
        xt.sec += 5;
                std::cout << "will wait until: " << xt.sec << std::endl;
                if (!cvar.timed_wait(lock, xt))
                        std::cout << "timed out!" << std::endl;
                std::cout << "next step" << std::endl;

int main(int argc, char* argv[])
    boost::thread thrd1(&thread1);
    return 0;
// -------------------------------

2. The secound trouble is that the thread function has catch(...) at the root and
when unhandled exception in thread thrown, it's just silently eated and thread stopped.
But the process stay alive, and now nothing about it.
And ever wrong that catch(...) under VC6 will catch OS exceptions.

p.s. sorry for so bad english

Boost list run by bdawes at, gregod at, cpdaniel at, john at