ldas-tools-al  2.6.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
LDASTools::AL::ReadWriteLock::baton_type Class Reference

Manager of the read/write lock resource. More...

#include <ReadWriteLock.hh>

Public Member Functions

 baton_type (bool Logging=true)
 Constructor. More...
 
void * Handle ()
 Return pointer to low level data storage. More...
 
void Lock (mode_type Mode, const char *const File, const size_t Line)
 Request the resource to be locked. More...
 
void Lock (mode_type Mode, bool TryLock, const char *const File, const size_t Line)
 Request the resource to be locked. More...
 
void Lock (mode_type Mode, size_t Timeout, const char *const File, const size_t Line)
 Request the resource to be locked. More...
 
void TryLock (mode_type Mode, const char *const File, const size_t Line)
 Request the resource to be locked without waiting. More...
 
void Unlock (const char *const File, const size_t Line)
 Release any locks held on the resource. More...
 
void reset ()
 Destroy the resources associated with this instance.
 

Detailed Description

Manager of the read/write lock resource.

Constructor & Destructor Documentation

LDASTools::AL::ReadWriteLock::baton_type::baton_type ( bool  Logging = true)

Constructor.

Parameters
[in]LoggingIf true, then all actions associated with this instance will be logged for DeadLockDetector.

Member Function Documentation

void * LDASTools::AL::ReadWriteLock::baton_type::Handle ( )

Return pointer to low level data storage.

Returns
Pointer to low level data storage.
Note
This should be used very sparingly since the library used to implement this fuctionality may change.
void LDASTools::AL::ReadWriteLock::baton_type::Lock ( mode_type  Mode,
const char *const  File,
const size_t  Line 
)
inline

Request the resource to be locked.

Parameters
[in]ModeAny of the lock_modes.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.
try {
l.Lock( ReadWriteLock::READ, __FILE__, __LINE__ );
}
catch( const ReadWriteLock::BusyError& Exception )
{
// Do something since the lock could not be acquired
...
}
catch( const ReadWriteLock::DeadLockError& Exception )
{
// Do something since the lock could not be acquired
...
}
void LDASTools::AL::ReadWriteLock::baton_type::Lock ( mode_type  Mode,
bool  TryLock,
const char *const  File,
const size_t  Line 
)

Request the resource to be locked.

Parameters
[in]ModeAny of the lock_modes.
[in]TryLockIf true, then return immediately wether or not the lock was obtained.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.
try {
l.Lock( ReadWriteLock::READ, true, __FILE__, __LINE__ );
}
catch( const ReadWrieLock::BusyError& Exception )
{
// Do something since the lock could not be acquired
...
}
catch( const ReadWrieLock::DeadLockError& Exception )
{
// Do something since the lock could not be acquired
...
}
void LDASTools::AL::ReadWriteLock::baton_type::Lock ( mode_type  Mode,
size_t  Timeout,
const char *const  File,
const size_t  Line 
)

Request the resource to be locked.

Parameters
[in]ModeAny of the lock_modes.
[in]TimeoutTime limit in seconds in which to acquire the lock. A value of zero (0) indicates that the method should wait until the lock is granted.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.
void LDASTools::AL::ReadWriteLock::baton_type::TryLock ( mode_type  Mode,
const char *const  File,
const size_t  Line 
)
inline

Request the resource to be locked without waiting.

Parameters
[in]ModeAny of the lock_modes.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.

The TryLock method tries to lock the resouce. If the resouce is locked prior to this call, then the method returns immediately by throwing the ReadWriteLock::BusyError exception.

try {
l.TryLock( ReadWriteLock::READ, __FILE__, __LINE__ );
}
catch( const ReadWriteLock::BusyError& Exception )
{
// Do something since the lock could not be acquired
...
}
catch( const ReadWriteLock::DeadLockError& Exception )
{
// Do something since the lock could not be acquired
...
}
void LDASTools::AL::ReadWriteLock::baton_type::Unlock ( const char *const  File,
const size_t  Line 
)

Release any locks held on the resource.

Parameters
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.

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