Boost logo

Boost :

From: Janusz Piwowarski (jpiw_at_[hidden])
Date: 2004-11-08 03:34:56


Hi all,

When Boost.Thread is compiled in release mode, there are a lot of warnings
about unused variable 'int loop_count' in read_write_mutex.cpp. They comes
from code like:

int loop_count = 0;
while (m_state == -1)
{
    BOOST_ASSERT(++loop_count == 1);
    ++m_num_waiting_readers;
    m_waiting_readers.wait(l);
    --m_num_waiting_readers;
}

If loop is for second evaluation of condition only, i think it would be
better to write:

if (m_state == -1)
{
    ++m_num_waiting_readers;
    m_waiting_readers.wait(l);
    --m_num_waiting_readers;
    BOOST_ASSERT(m_state != -1);
}

Regards,
Janusz


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk