ExternalLockSync.h

Classes

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

class ExternalLockSync

Interface

Public Members
ExternalLockSync (const TableLock& lockOptions)
~ExternalLockSync()
void makeLock (const String& tableName, Bool create, FileLocker::LockType)
Bool acquire (FileLocker::LockType = FileLocker::Write, uInt nattempts = 0)
uInt nrow() const
void release (uInt nrrow)
Bool hasLock (FileLocker::LockType) const
Private Members
ExternalLockSync (const ExternalLockSync& that)
ExternalLockSync& operator= (const ExternalLockSync& that)
static MemoryIO* releaseCallBack (void* lockSyncObject, Bool always)
MemoryIO* doReleaseCallBack (Bool always)

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

ExternalLockSync (const TableLock& lockOptions)

Construct from the given TableLock object.

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

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

uInt nrow() const

Get the current number of rows in this object.

void release (uInt nrrow)

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.

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.

ExternalLockSync (const ExternalLockSync& that)

Copy constructor is forbidden.

ExternalLockSync& operator= (const ExternalLockSync& that)

Assignment is forbidden.

static MemoryIO* releaseCallBack (void* lockSyncObject, Bool always)

The callback function when releasing a lock.

MemoryIO* doReleaseCallBack (Bool always)

The member function executing the callback functionality.