Public Member Functions

atscppapi::ScopedMutexTryLock Class Reference

Take a Mutex reference and try to lock inside a scope and unlock when the scope is exited (if the lock was taken). More...

#include <Mutex.h>

Inherits atscppapi::noncopyable.

Collaboration diagram for atscppapi::ScopedMutexTryLock:
Collaboration graph
[legend]

Public Member Functions

 ScopedMutexTryLock (Mutex &mutex)
 Try to create the scoped mutex lock, if you should check hasLock() to determine if this object was successfully able to take the lock.
 ~ScopedMutexTryLock ()
 Unlock the mutex (if we hold the lock).
bool hasLock ()

Detailed Description

Take a Mutex reference and try to lock inside a scope and unlock when the scope is exited (if the lock was taken).

This is an RAII implementation which will lock a mutex at the start of the scope and unlock it when the scope is exited if the lock was taken.

See also:
Mutex

Definition at line 177 of file Mutex.h.


Constructor & Destructor Documentation

atscppapi::ScopedMutexTryLock::ScopedMutexTryLock ( Mutex mutex  )  [inline, explicit]

Try to create the scoped mutex lock, if you should check hasLock() to determine if this object was successfully able to take the lock.

Parameters:
mutex a shared pointer to a Mutex.

Definition at line 183 of file Mutex.h.

References atscppapi::Mutex::tryLock().

atscppapi::ScopedMutexTryLock::~ScopedMutexTryLock (  )  [inline]

Unlock the mutex (if we hold the lock).

Definition at line 191 of file Mutex.h.

References atscppapi::Mutex::unlock().


Member Function Documentation

bool atscppapi::ScopedMutexTryLock::hasLock (  )  [inline]
Returns:
True if the lock was taken, False if it was not taken.

Definition at line 200 of file Mutex.h.


The documentation for this class was generated from the following file: