he TryGuard is used to attempt to gain writer access. The constructor makes
one attempt to write-lock the mutex. Afterwards the success of such attempt
may be tested by accessing the "operator bool() const" of the TryGuard.
The following is the public interface.
class BadTryGuard: public boost::exception, public
std::exception {};
template <class X, class Mutex>
class
TryGuard
{
public:
explicit
TryGuard( volatile X& x );
explicit
TryGuard( volatile X* x );
TryGuard(
volatile X& x, volatile const Mutex& mutex );
TryGuard(
volatile X* x, volatile const Mutex& mutex );
~TryGuard();
operator
bool() const;
Mutex&
mutex() const;
X*
ptr() const;
X*
operator->();
X&
operator*();
};
All constructors throw boost::thread_resource_error. The BadTryGuard is thrown
when accessing the X while bool() is false.
|