Boost logo

Boost :

Subject: Re: [boost] Portable robust mutex an another try...
From: Jonathan Wakely (jwakely.boost_at_[hidden])
Date: 2014-07-24 18:48:11


On 15 July 2014 16:42, Ladislav Sopko wrote:
> Hello,
>
> I did try to continue with */Ion Gaztanaga's /*idea of portable robust
> mutex.
> I post my code and considerations in codereview.
>
> http://codereview.stackexchange.com/questions/57083/portable-c-boostiterprocessmutex-an-another-try
>
> I hope to find some one to discuss about.

I'll have to take a good look at that code.

In my attempt to implement a robust mutex that models the C++11 Mutex
concept I decided to add a new overload of try_lock, taking a tag type
to indicate you are prepared to deal with the inconsistent state. The
C++11 try_lock() function only returns true or false, which can't
support the third state that can occur when locking a robust mutex,
and I didn't want to rely on users calling an extra function to query
whether a successful try_lock was *really* successful (in generic code
working with any Mutex type failing to handle the inconsistent state
could be disastrous).

If you call the normal zero-argument try_lock() on my type and it's
inconsistent you get an exception and it's marked as unrecoverable. If
you call the try_lock(robust_t) overload you get a chance to recover
it.

https://gitorious.org/redistd/redistd/source/0d9c849726729e66e5703fadba0222d6df724533:include/redi/posix_mutex.h#L142


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