In a class, I want to use a mutex over a function like this
void Agent::notify(Packet& packet, Peer peer) {
boost::mutex::scoped_lock lock(mutex_);
...
}
No problem at the compilation process. But when I execute the program, boost always fail at this line saying :
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
what(): boost: mutex lock failed in pthread_mutex_lock: Invalid argument
Abandon (core dumped)
I try to use lock()
or unlock
methods, but the same problem. When I use try_lock
it doesn't failed by the condition is always false.
Searching on internet I found this https://svn.boost.org/trac/boost/ticket/9307 .
But I think the problem is my program but I don't see where. In my tests there is only one thread that go in this function.
mutex_
declared/defined? is it locked recursively? – Slideaction