I am trying to solve the blocking problem with Boost 1.46.1 - I tried several things, but I am not happy - and therefore would like to hear the inputs from a clean cut.
Topic A:
- Always have to wait and get a lock for the important data section.
- Updates some important data.
- Manual unlock (or scope)
Topic B - Never block (try_lock?) - Reads data from the critical section mentioned, if the received lock
I am not sure if I need shared_lock or I can solve it differently.
EDIT, my code looks like this: Topic A:
{
boost::mutex::scoped_lock lock( _mutex) ;
}
Theme B:
boost::mutex::scoped_lock lock(_mutex, boost::try_to_lock);
if( lock ) {
}
But I could not register the failed try_lock - so I wonder if this really works.
Regards, Paul
source
share