casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
casacore::TableLockData Class Reference

Class to hold table lock data. More...

#include <TableLockData.h>

Inheritance diagram for casacore::TableLockData:
casacore::TableLock

Public Types

typedef MemoryIOReleaseCallBack (void *parentObject, Bool always)
 Define the signature of the callback function when a lock is released. More...
 
- Public Types inherited from casacore::TableLock
enum  LockOption {
  PermanentLocking,
  PermanentLockingWait,
  AutoLocking,
  UserLocking,
  AutoNoReadLocking,
  UserNoReadLocking,
  NoLocking,
  DefaultLocking
}
 Define the possible table locking options. More...
 

Public Member Functions

 TableLockData (const TableLock &lockOptions, ReleaseCallBack *=0, void *releaseParentObject=0)
 Construct from the given TableLock object. More...
 
 ~TableLockData ()
 
void makeLock (const String &name, Bool create, FileLocker::LockType, uInt locknr=0)
 Create the LockFile object and acquire a read or write lock when permanent locking is in effect. More...
 
Bool acquire (MemoryIO *info, FileLocker::LockType, uInt nattempts)
 Acquire a read or write lock. More...
 
void release (Bool always=False)
 Release the lock. More...
 
void autoRelease (Bool always=False)
 When the inspection interval has expired, inspect if another process needs the lock. More...
 
Bool hasLock (FileLocker::LockType) const
 Has this process the read or write lock, thus can the table be read or written safely? More...
 
Bool isMultiUsed () const
 Is the table in use (i.e. More...
 
void getInfo (MemoryIO &info)
 Get or put the info in the lock file. More...
 
void putInfo (const MemoryIO &info)
 
- Public Member Functions inherited from casacore::TableLock
 TableLock (LockOption option=DefaultLocking)
 Construct with given option and interval. More...
 
 TableLock (LockOption option, double inspectionInterval, uInt maxWait=0)
 
 TableLock (const TableLock &that)
 Copy constructor. More...
 
TableLockoperator= (const TableLock &that)
 Assignment. More...
 
void merge (const TableLock &that)
 Merge that TableLock with this TableLock object by taking the maximum option and minimum inspection interval. More...
 
LockOption option () const
 Get the locking option. More...
 
Bool readLocking () const
 Is read locking needed? More...
 
Bool isPermanent () const
 Is permanent locking used? More...
 
double interval () const
 Get the inspection interval. More...
 
uInt maxWait () const
 Get the maximum wait period in AutoLocking mode. More...
 

Private Member Functions

 TableLockData (const TableLockData &that)
 Copy constructor is forbidden. More...
 
TableLockDataoperator= (const TableLockData &that)
 Assignment is forbidden. More...
 

Private Attributes

LockFileitsLock
 
ReleaseCallBackitsReleaseCallBack
 
void * itsReleaseParent
 

Additional Inherited Members

- Static Public Member Functions inherited from casacore::TableLock
static Bool lockingDisabled ()
 Is table locking disabled (because AIPS_TABLE_NOLOCKING or table.nolocking is set)? More...
 

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 63 of file TableLockData.h.

Member Typedef Documentation

typedef MemoryIO* casacore::TableLockData::ReleaseCallBack(void *parentObject, Bool always)

Define the signature of the callback function when a lock is released.

The flag always tells if the callback function should always write its main data (meant for case that table gets closed). The callback function has to write the synchronization data (preferably in canonical format) in a MemoryIO object. A pointer to this MemoryIO object has to be returned. A zero pointer can be returned when no synchronization data is available.

Definition at line 73 of file TableLockData.h.

Constructor & Destructor Documentation

casacore::TableLockData::TableLockData ( const TableLock lockOptions,
ReleaseCallBack = 0,
void *  releaseParentObject = 0 
)

Construct from the given TableLock object.

casacore::TableLockData::~TableLockData ( )
casacore::TableLockData::TableLockData ( const TableLockData that)
private

Copy constructor is forbidden.

Member Function Documentation

Bool casacore::TableLockData::acquire ( MemoryIO info,
FileLocker::LockType  ,
uInt  nattempts 
)

Acquire a read or write lock.

It throws an exception when acquire failed while it had to wait.

void casacore::TableLockData::autoRelease ( Bool  always = False)
inline

When the inspection interval has expired, inspect if another process needs the lock.

If so, release the lock. always=True means that the inspection is always done, thus not every 25th call or so.

Definition at line 138 of file TableLockData.h.

References casacore::TableLock::AutoLocking, casacore::LockFile::inspect(), itsLock, casacore::TableLock::option(), and release().

Referenced by casacore::ColumnSet::autoReleaseLock().

void casacore::TableLockData::getInfo ( MemoryIO info)
inline

Get or put the info in the lock file.

Definition at line 150 of file TableLockData.h.

References casacore::LockFile::getInfo(), and itsLock.

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

Has this process the read or write lock, thus can the table be read or written safely?

Definition at line 134 of file TableLockData.h.

References casacore::LockFile::hasLock(), itsLock, and casacore::True.

Referenced by casacore::ColumnSet::checkReadLock(), casacore::ColumnSet::checkWriteLock(), and casacore::ExternalLockSync::hasLock().

Bool casacore::TableLockData::isMultiUsed ( ) const
inline

Is the table in use (i.e.

open) in another process?

Definition at line 144 of file TableLockData.h.

References casacore::LockFile::isMultiUsed(), and itsLock.

void casacore::TableLockData::makeLock ( const String name,
Bool  create,
FileLocker::LockType  ,
uInt  locknr = 0 
)

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.

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

Assignment is forbidden.

void casacore::TableLockData::putInfo ( const MemoryIO info)
inline

Definition at line 154 of file TableLockData.h.

References itsLock, and casacore::LockFile::putInfo().

void casacore::TableLockData::release ( Bool  always = False)

Release the lock.

When always==False, the lock is not released when a permanent lock is used. It does nothing when permanent locking is used. It throws an exception when the release failed. When the lock is released, the release callback function (if defined) is called to write the synchronization data.

Referenced by autoRelease(), casacore::ExternalLockSync::release(), and casacore::ColumnSet::userUnlock().

Member Data Documentation

LockFile* casacore::TableLockData::itsLock
private

Definition at line 127 of file TableLockData.h.

Referenced by autoRelease(), getInfo(), hasLock(), isMultiUsed(), and putInfo().

ReleaseCallBack* casacore::TableLockData::itsReleaseCallBack
private

Definition at line 129 of file TableLockData.h.

void* casacore::TableLockData::itsReleaseParent
private

Definition at line 130 of file TableLockData.h.


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