Boost logo

Boost Users :

From: Christopher Currie (Christopher_at_[hidden])
Date: 2003-05-19 13:19:55


I've been looking at the implementation of recursive_try_mutex, and
something struck me as odd in the pthreads implementation:

bool recursive_try_mutex::do_trylock()
{
# if defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
     int res = 0;
     res = pthread_mutex_trylock(&m_mutex);
     assert(res == 0);

     if (res == 0)
     {
         if (++m_count > 1)
         {
             res = pthread_mutex_unlock(&m_mutex);
             assert(res == 0);
         }
         return true;
     }

     return false;
# else
// ...
}

It appears that if BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE is defined, in
debug mode this function will never return false, because the assert
will fire first instead. Am I reading this incorrectly, or is there
something happening somewhere else that I'm missing?

Thanks in advance,
Christopher Currie

[Non-text portions of this message have been removed]


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