casacore
|
Class to hold table lock data. More...
#include <TableLockData.h>
Public Types | |
typedef MemoryIO * | ReleaseCallBack (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... | |
TableLock & | operator= (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... | |
TableLockData & | operator= (const TableLockData &that) |
Assignment is forbidden. More... | |
Private Attributes | |
LockFile * | itsLock |
ReleaseCallBack * | itsReleaseCallBack |
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... | |
Class to hold table lock data.
Internal
This class keeps the LockFile
object used to do the actual locking/unlocking. It also keeps the synchronization information.
Encapsulate Table locking data.
Definition at line 63 of file TableLockData.h.
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.
casacore::TableLockData::TableLockData | ( | const TableLock & | lockOptions, |
ReleaseCallBack * | = 0 , |
||
void * | releaseParentObject = 0 |
||
) |
Construct from the given TableLock object.
casacore::TableLockData::~TableLockData | ( | ) |
|
private |
Copy constructor is forbidden.
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.
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().
|
inline |
Get or put the info in the lock file.
Definition at line 150 of file TableLockData.h.
References casacore::LockFile::getInfo(), and itsLock.
|
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().
|
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.
|
private |
Assignment is forbidden.
|
inline |
Definition at line 154 of file TableLockData.h.
References itsLock, and casacore::LockFile::putInfo().
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().
|
private |
Definition at line 127 of file TableLockData.h.
Referenced by autoRelease(), getInfo(), hasLock(), isMultiUsed(), and putInfo().
|
private |
Definition at line 129 of file TableLockData.h.
|
private |
Definition at line 130 of file TableLockData.h.