Boost logo

Boost Users :

From: Russell Hind (yg-boost-users_at_[hidden])
Date: 2003-02-21 11:54:03


The start of the do_wait() method of a boost::condition (in 1.29.0) for
Win32 looks like this

void condition::do_wait()
{
    int res = 0;
    res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_queue), INFINITE);
    assert(res == WAIT_OBJECT_0);

This waits indefinitely until m_queue is signalled. Would it be safe to
change this so the thread is alertable for IO completion routines?
Something like

int res = 0;
while ((res = WaitForSingleObjectEx(reinterpret_cast<HANDLE>(m_queue),
INFINITE, true)) == WAIT_IO_COMPLETION)
{
}
assert (res == WAIT_OBJECT_0);

We make fairly heavy use of Waitable Timers in our statemachines. The
completion routine for a timer is called back in the context of the thread
that started it, when the thread is alertable. WaitForSingleObject doesn't
allow the thread to be alertable.

We currently use this in our own thread (with Windows events) but are
looking to update the message queue code and thread code to use boost. With
out this change, it would currently break a lot of code if we were to use
condition variables.

Thanks

Russell


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net