ldas-tools-al  2.6.5
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
LDASTools::AL::ReadWriteLock Class Reference

Implements read/write lock symantics. More...

#include <ReadWriteLock.hh>

Inheritance diagram for LDASTools::AL::ReadWriteLock:
Inheritance graph
[legend]
Collaboration diagram for LDASTools::AL::ReadWriteLock:
Collaboration graph
[legend]

Classes

class  baton_type
 Manager of the read/write lock resource. More...
 
class  BusyError
 Busy lock error. More...
 
class  DeadLockError
 Deadlock error. More...
 
class  TimedoutError
 Time out error. More...
 

Public Types

enum  lock_mode {
  NONE = 0x0000, READ = 0x0001, WRITE = 0x0002, NONE = 0x0000,
  READ = 0x0001, WRITE = 0x0002, NONE = 0x0000, READ = 0x0001,
  WRITE = 0x0002
}
 Lock mode. More...
 
enum  lock_state {
  STATE_NONE = 0x0000, PENDING = 0x0001, ACTIVE = 0x0002, STATE_NONE = 0x0000,
  PENDING = 0x0001, ACTIVE = 0x0002, STATE_NONE = 0x0000, PENDING = 0x0001,
  ACTIVE = 0x0002
}
 Lock state. More...
 
enum  lock_mode {
  NONE = 0x0000, READ = 0x0001, WRITE = 0x0002, NONE = 0x0000,
  READ = 0x0001, WRITE = 0x0002, NONE = 0x0000, READ = 0x0001,
  WRITE = 0x0002
}
 Lock mode. More...
 
enum  lock_state {
  STATE_NONE = 0x0000, PENDING = 0x0001, ACTIVE = 0x0002, STATE_NONE = 0x0000,
  PENDING = 0x0001, ACTIVE = 0x0002, STATE_NONE = 0x0000, PENDING = 0x0001,
  ACTIVE = 0x0002
}
 Lock state. More...
 
enum  lock_mode {
  NONE = 0x0000, READ = 0x0001, WRITE = 0x0002, NONE = 0x0000,
  READ = 0x0001, WRITE = 0x0002, NONE = 0x0000, READ = 0x0001,
  WRITE = 0x0002
}
 Lock mode. More...
 
enum  lock_state {
  STATE_NONE = 0x0000, PENDING = 0x0001, ACTIVE = 0x0002, STATE_NONE = 0x0000,
  PENDING = 0x0001, ACTIVE = 0x0002, STATE_NONE = 0x0000, PENDING = 0x0001,
  ACTIVE = 0x0002
}
 Lock state. More...
 
typedef enum LDASTools::AL::ReadWriteLock::lock_mode mode_type
 Lock mode. More...
 
typedef enum LDASTools::AL::ReadWriteLock::lock_mode mode_type
 Lock mode. More...
 
typedef enum LDASTools::AL::ReadWriteLock::lock_mode mode_type
 Lock mode. More...
 

Public Member Functions

 ReadWriteLock (baton_type Lock, mode_type Mode, const char *Filename, int Linenum)
 Constructor. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, bool TryLock, const char *Filename, int Linenum)
 Constructor. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, int Timeout, const char *Filename, int Linenum)
 Constructor. More...
 
virtual ~ReadWriteLock ()
 Destructor. More...
 
void Modify (mode_type Mode, const char *Filename, int Linenum)
 Modify the mode of lock being held on the resource. More...
 
void Release (const char *Filename, int Linenum)
 Release the lock. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, const char *Filename, int Linenum)
 Constructor. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, bool TryLock, const char *Filename, int Linenum)
 Constructor. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, int Timeout, const char *Filename, int Linenum)
 Constructor. More...
 
virtual ~ReadWriteLock ()
 Destructor. More...
 
void Modify (mode_type Mode, const char *Filename, int Linenum)
 Modify the mode of lock being held on the resource. More...
 
void Release (const char *Filename, int Linenum)
 Release the lock. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, const char *Filename, int Linenum)
 Constructor. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, bool TryLock, const char *Filename, int Linenum)
 Constructor. More...
 
 ReadWriteLock (baton_type Lock, mode_type Mode, int Timeout, const char *Filename, int Linenum)
 Constructor. More...
 
virtual ~ReadWriteLock ()
 Destructor. More...
 
void Modify (mode_type Mode, const char *Filename, int Linenum)
 Modify the mode of lock being held on the resource. More...
 
void Release (const char *Filename, int Linenum)
 Release the lock. More...
 

Static Public Member Functions

static baton_type Baton ()
 Create a baton that is appropriate for use with this class. More...
 
static int Interval (int Value)
 
static int Timeout (int Value)
 
static void ThreadCancel (void *VLock)
 Handler for thead cancelation. More...
 
static baton_type Baton ()
 Create a baton that is appropriate for use with this class. More...
 
static int Interval (int Value)
 
static int Timeout (int Value)
 
static void ThreadCancel (void *VLock)
 Handler for thead cancelation. More...
 
static baton_type Baton ()
 Create a baton that is appropriate for use with this class. More...
 
static int Interval (int Value)
 
static int Timeout (int Value)
 
static void ThreadCancel (void *VLock)
 Handler for thead cancelation. More...
 

Private Attributes

baton_type sync_baton
 

Detailed Description

Implements read/write lock symantics.

This class provides proper garbage collection of system resource used to implement thread safe read/write locks.

ReadWriteLock::baton_type baton;
void
threaded_func()
{
__FILE__, __LINE__ );
// modify things that should only be done by a single thread
...
// As lock goes out of scope, the destructor is called
// thereby releasing lock held on baton.
}

Member Typedef Documentation

◆ mode_type [1/3]

Lock mode.

◆ mode_type [2/3]

Lock mode.

◆ mode_type [3/3]

Lock mode.

Member Enumeration Documentation

◆ lock_mode [1/3]

Lock mode.

Enumerator
NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

◆ lock_mode [2/3]

Lock mode.

Enumerator
NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

◆ lock_mode [3/3]

Lock mode.

Enumerator
NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

NONE 
READ 

< Initial mode

WRITE 

< Read lock allows multiple concurrent reads.

◆ lock_state [1/3]

Lock state.

Enumerator
STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

◆ lock_state [2/3]

Lock state.

Enumerator
STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

◆ lock_state [3/3]

Lock state.

Enumerator
STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

STATE_NONE 
PENDING 

< Initial state

ACTIVE 

< Lock requested

Constructor & Destructor Documentation

◆ ReadWriteLock() [1/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.
l.Lock( ReadWriteLock::READ, __FILE__, __LINE__ );

◆ ReadWriteLock() [2/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
bool  TryLock,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.

◆ ReadWriteLock() [3/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
int  Timeout,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.

◆ ~ReadWriteLock() [1/3]

LDASTools::AL::ReadWriteLock::~ReadWriteLock ( )
virtual

Destructor.

◆ ReadWriteLock() [4/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.
l.Lock( ReadWriteLock::READ, __FILE__, __LINE__ );

◆ ReadWriteLock() [5/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
bool  TryLock,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.

◆ ReadWriteLock() [6/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
int  Timeout,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.

◆ ~ReadWriteLock() [2/3]

virtual LDASTools::AL::ReadWriteLock::~ReadWriteLock ( )
virtual

Destructor.

◆ ReadWriteLock() [7/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.
l.Lock( ReadWriteLock::READ, __FILE__, __LINE__ );

◆ ReadWriteLock() [8/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
bool  TryLock,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.

◆ ReadWriteLock() [9/9]

LDASTools::AL::ReadWriteLock::ReadWriteLock ( baton_type  Lock,
mode_type  Mode,
int  Timeout,
const char *  Filename,
int  Linenum 
)

Constructor.

Parameters
[in]LockBaton controlling access to the resource.
[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.

◆ ~ReadWriteLock() [3/3]

virtual LDASTools::AL::ReadWriteLock::~ReadWriteLock ( )
virtual

Destructor.

Member Function Documentation

◆ Baton() [1/3]

ReadWriteLock::baton_type LDASTools::AL::ReadWriteLock::Baton ( )
static

Create a baton that is appropriate for use with this class.

◆ Baton() [2/3]

static baton_type LDASTools::AL::ReadWriteLock::Baton ( )
static

Create a baton that is appropriate for use with this class.

◆ Baton() [3/3]

static baton_type LDASTools::AL::ReadWriteLock::Baton ( )
static

Create a baton that is appropriate for use with this class.

◆ Interval() [1/3]

int LDASTools::AL::ReadWriteLock::Interval ( int  Value)
static

◆ Interval() [2/3]

static int LDASTools::AL::ReadWriteLock::Interval ( int  Value)
static

◆ Interval() [3/3]

static int LDASTools::AL::ReadWriteLock::Interval ( int  Value)
static

◆ Modify() [1/3]

void LDASTools::AL::ReadWriteLock::Modify ( mode_type  Mode,
const char *  Filename,
int  Linenum 
)

Modify the mode of lock being held on the resource.

Parameters
[in]ModeThe new mode to be held on the resource.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.

◆ Modify() [2/3]

void LDASTools::AL::ReadWriteLock::Modify ( mode_type  Mode,
const char *  Filename,
int  Linenum 
)

Modify the mode of lock being held on the resource.

Parameters
[in]ModeThe new mode to be held on the resource.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.

◆ Modify() [3/3]

void LDASTools::AL::ReadWriteLock::Modify ( mode_type  Mode,
const char *  Filename,
int  Linenum 
)

Modify the mode of lock being held on the resource.

Parameters
[in]ModeThe new mode to be held on the resource.
[in]FileThe filename from where the call was made.
[in]LineThe line number from where the call was made.

◆ Release() [1/3]

void LDASTools::AL::ReadWriteLock::Release ( const char *  Filename,
int  Linenum 
)

Release the lock.

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

◆ Release() [2/3]

void LDASTools::AL::ReadWriteLock::Release ( const char *  Filename,
int  Linenum 
)

Release the lock.

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

◆ Release() [3/3]

void LDASTools::AL::ReadWriteLock::Release ( const char *  Filename,
int  Linenum 
)

Release the lock.

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

◆ ThreadCancel() [1/3]

static void LDASTools::AL::ReadWriteLock::ThreadCancel ( void *  VLock)
static

Handler for thead cancelation.

Parameters
[in]VLockThe VLock is a pointer to a ReadWriteLock object that holds a lock.

◆ ThreadCancel() [2/3]

static void LDASTools::AL::ReadWriteLock::ThreadCancel ( void *  VLock)
static

Handler for thead cancelation.

Parameters
[in]VLockThe VLock is a pointer to a ReadWriteLock object that holds a lock.

◆ ThreadCancel() [3/3]

static void LDASTools::AL::ReadWriteLock::ThreadCancel ( void *  VLock)
static

Handler for thead cancelation.

Parameters
[in]VLockThe VLock is a pointer to a ReadWriteLock object that holds a lock.

◆ Timeout() [1/3]

static int LDASTools::AL::ReadWriteLock::Timeout ( int  Value)
static

◆ Timeout() [2/3]

int LDASTools::AL::ReadWriteLock::Timeout ( int  Value)
static

◆ Timeout() [3/3]

static int LDASTools::AL::ReadWriteLock::Timeout ( int  Value)
static

Member Data Documentation

◆ sync_baton

baton_type LDASTools::AL::ReadWriteLock::sync_baton
private

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