casacore
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
casacore::ExternalLockSync Class Reference

More...

#include <ExternalLockSync.h>

Public Member Functions

 ExternalLockSync (const TableLock &lockOptions)
 Construct from the given TableLock object. More...
 
 ~ExternalLockSync ()
 
void makeLock (const String &tableName, Bool create, FileLocker::LockType)
 Create the LockFile object and acquire a read or write lock when permanent locking is in effect. More...
 
Bool acquire (FileLocker::LockType=FileLocker::Write, uInt nattempts=0)
 Acquire a read or write lock (when needed). More...
 
rownr_t nrow () const
 Get the current number of rows in this object. More...
 
void release (rownr_t nrrow)
 Release the lock and synchronize the table access. More...
 
Bool hasLock (FileLocker::LockType) const
 Check if the table has a read or write lock, thus if the table can be read or written safely. More...
 

Private Member Functions

 ExternalLockSync (const ExternalLockSync &that)
 Copy constructor is forbidden. More...
 
ExternalLockSyncoperator= (const ExternalLockSync &that)
 Assignment is forbidden. More...
 
MemoryIOdoReleaseCallBack (Bool always)
 The member function executing the callback functionality. More...
 

Static Private Member Functions

static MemoryIOreleaseCallBack (void *lockSyncObject, Bool always)
 The callback function when releasing a lock. More...
 

Private Attributes

TableLockData itsLock
 
TableSyncData itsSync
 
rownr_t itsNrrow
 

Detailed Description


Class to hold table lock data.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tTable

Prerequisite

Synopsis

This class keeps the LockFile object used to do the actual locking/unlocking. It also keeps the synchronization information.

Motivation

Encapsulate Table locking data.

Definition at line 64 of file ExternalLockSync.h.

Constructor & Destructor Documentation

◆ ExternalLockSync() [1/2]

casacore::ExternalLockSync::ExternalLockSync ( const TableLock lockOptions)

Construct from the given TableLock object.

◆ ~ExternalLockSync()

casacore::ExternalLockSync::~ExternalLockSync ( )

◆ ExternalLockSync() [2/2]

casacore::ExternalLockSync::ExternalLockSync ( const ExternalLockSync that)
private

Copy constructor is forbidden.

Member Function Documentation

◆ acquire()

Bool casacore::ExternalLockSync::acquire ( FileLocker::LockType  = FileLocker::Write,
uInt  nattempts = 0 
)

Acquire a read or write lock (when needed).

Nattempts==0 indicates that it has to wait until the lock is acquired. Nattempts>0 indicates that it gives up acquiring the lock when nattempts have been done (with 1 second intervals). It throws an exception when acquire failed while it had to wait. It returns a false status when acquiring the lock failed while it does not have to wait.
When a lock is successfully acquired, the number of rows (see function nrrow() below) is reset as a result of synchronizing the access to the table.

◆ doReleaseCallBack()

MemoryIO * casacore::ExternalLockSync::doReleaseCallBack ( Bool  always)
inlineprivate

The member function executing the callback functionality.

Definition at line 134 of file ExternalLockSync.h.

References itsNrrow, itsSync, casacore::TableSyncData::memoryIO(), and casacore::TableSyncData::write().

◆ hasLock()

Bool casacore::ExternalLockSync::hasLock ( FileLocker::LockType  type) const
inline

Check if the table has a read or write lock, thus if the table can be read or written safely.

Definition at line 125 of file ExternalLockSync.h.

References casacore::TableLockData::hasLock(), and itsLock.

◆ makeLock()

void casacore::ExternalLockSync::makeLock ( const String tableName,
Bool  create,
FileLocker::LockType   
)

Create the LockFile object and acquire a read or write lock when permanent locking is in effect.

It throws an exception when acquiring the lock failed.

◆ nrow()

rownr_t casacore::ExternalLockSync::nrow ( ) const
inline

Get the current number of rows in this object.

Definition at line 139 of file ExternalLockSync.h.

References itsNrrow.

◆ operator=()

ExternalLockSync& casacore::ExternalLockSync::operator= ( const ExternalLockSync that)
private

Assignment is forbidden.

◆ release()

void casacore::ExternalLockSync::release ( rownr_t  nrrow)
inline

Release the lock and synchronize the table access.

When autolocking is in effect, the lock is only released when the inspection-interval (see class TableLockData) has expired. It does nothing when permanent locking is used. It throws an exception when the release failed.

Definition at line 129 of file ExternalLockSync.h.

References itsLock, itsNrrow, and casacore::TableLockData::release().

◆ releaseCallBack()

static MemoryIO* casacore::ExternalLockSync::releaseCallBack ( void *  lockSyncObject,
Bool  always 
)
staticprivate

The callback function when releasing a lock.

Member Data Documentation

◆ itsLock

TableLockData casacore::ExternalLockSync::itsLock
private

Definition at line 119 of file ExternalLockSync.h.

Referenced by hasLock(), and release().

◆ itsNrrow

rownr_t casacore::ExternalLockSync::itsNrrow
private

Definition at line 121 of file ExternalLockSync.h.

Referenced by doReleaseCallBack(), nrow(), and release().

◆ itsSync

TableSyncData casacore::ExternalLockSync::itsSync
private

Definition at line 120 of file ExternalLockSync.h.

Referenced by doReleaseCallBack().


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