casa
$Rev:20696$
|
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. | |
Public Member Functions | |
TableLockData (const TableLock &lockOptions, ReleaseCallBack *=0, void *releaseParentObject=0) | |
Construct from the given TableLock object. | |
~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. | |
Bool | acquire (MemoryIO *info, FileLocker::LockType, uInt nattempts) |
Acquire a read or write lock. | |
void | release (Bool always=False) |
Release the lock. | |
void | autoRelease (Bool always=False) |
When the inspection interval has expired, inspect if another process needs the lock. | |
Bool | hasLock (FileLocker::LockType) const |
Has this process the read or write lock, thus can the table be read or written safely? | |
Bool | isMultiUsed () const |
Is the table in use (i.e. | |
void | getInfo (MemoryIO &info) |
Get or put the info in the lock file. | |
void | putInfo (const MemoryIO &info) |
Private Member Functions | |
TableLockData (const TableLockData &that) | |
TableLockData & | operator= (const TableLockData &that) |
Assignment is forbidden. | |
Private Attributes | |
LockFile * | itsLock |
ReleaseCallBack * | itsReleaseCallBack |
void * | itsReleaseParent |
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.
typedef MemoryIO* casa::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.
casa::TableLockData::TableLockData | ( | const TableLock & | lockOptions, |
ReleaseCallBack * | = 0 , |
||
void * | releaseParentObject = 0 |
||
) |
Construct from the given TableLock object.
casa::TableLockData::TableLockData | ( | const TableLockData & | that | ) | [private] |
Copy constructor is forbidden.
Bool casa::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 casa::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 casa::TableLock::AutoLocking, casa::LockFile::inspect(), itsLock, casa::TableLock::option(), and release().
Referenced by casa::ColumnSet::autoReleaseLock().
void casa::TableLockData::getInfo | ( | MemoryIO & | info | ) | [inline] |
Get or put the info in the lock file.
Definition at line 150 of file TableLockData.h.
References casa::LockFile::getInfo(), and itsLock.
Bool casa::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 casa::LockFile::hasLock(), itsLock, and casa::True.
Referenced by casa::ColumnSet::checkReadLock(), casa::ColumnSet::checkWriteLock(), and casa::ExternalLockSync::hasLock().
Bool casa::TableLockData::isMultiUsed | ( | ) | const [inline] |
Is the table in use (i.e.
open) in another process?
Definition at line 144 of file TableLockData.h.
References casa::LockFile::isMultiUsed(), and itsLock.
void casa::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& casa::TableLockData::operator= | ( | const TableLockData & | that | ) | [private] |
Assignment is forbidden.
void casa::TableLockData::putInfo | ( | const MemoryIO & | info | ) | [inline] |
Definition at line 154 of file TableLockData.h.
References itsLock, and casa::LockFile::putInfo().
void casa::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(), casa::ExternalLockSync::release(), and casa::ColumnSet::userUnlock().
LockFile* casa::TableLockData::itsLock [private] |
Definition at line 127 of file TableLockData.h.
Referenced by autoRelease(), getInfo(), hasLock(), isMultiUsed(), and putInfo().
Definition at line 129 of file TableLockData.h.
void* casa::TableLockData::itsReleaseParent [private] |
Definition at line 130 of file TableLockData.h.