TableLockData.h

Classes

TableLockData -- Class to hold table lock data. (full description)

class TableLockData : public TableLock

Interface

Public Members
typedef MemoryIO* ReleaseCallBack (void* parentObject, Bool always)
TableLockData (const TableLock& lockOptions, ReleaseCallBack* = 0, void* releaseParentObject = 0)
~TableLockData()
void makeLock (const String& name, Bool create, FileLocker::LockType, uInt locknr = 0)
Bool acquire (MemoryIO* info, FileLocker::LockType, uInt nattempts)
void release (Bool always = False)
void autoRelease (Bool always=False)
Bool hasLock (FileLocker::LockType) const
Bool isMultiUsed() const
void getInfo (MemoryIO& info)
void putInfo (const MemoryIO& info)
Private Members
TableLockData (const TableLockData& that)
TableLockData& operator= (const TableLockData& that)

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

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.

Member Description

typedef MemoryIO* 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.

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. It throws an exception when acquiring the lock failed.

Bool 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 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.

void autoRelease (Bool always=False)

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.

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. open) in another process?

void getInfo (MemoryIO& info)
void putInfo (const MemoryIO& info)

Get or put the info in the lock file.

TableLockData (const TableLockData& that)

Copy constructor is forbidden.

TableLockData& operator= (const TableLockData& that)

Assignment is forbidden.