Loading...
Searching...
No Matches
casacore::TableLock Class Reference
tables package (libcasa_tables) » Tables_module » Tables_module_internal_classes

More...

`#include <TableLock.h>`

## Public Types

enum | LockOption { PermanentLocking , PermanentLockingWait , AutoLocking , UserLocking , AutoNoReadLocking , UserNoReadLocking , NoLocking , DefaultLocking }
| Define the possible table locking options. More...

## Public Member Functions

| TableLock (LockOption option=DefaultLocking)
| Construct with given option and interval.
| TableLock (LockOption option, double inspectionInterval, uInt maxWait=0)
| TableLock (const TableLock &that)
| Copy constructor.
TableLock & | operator= (const TableLock &that)
| Assignment.
void | merge (const TableLock &that)
| Merge that TableLock with this TableLock object by taking the maximum option and minimum inspection interval.
LockOption | option () const
| Get the locking option.
Bool | readLocking () const
| Is read locking needed?
Bool | isPermanent () const
| Is permanent locking used?
double | interval () const
| Get the inspection interval.
uInt | maxWait () const
| Get the maximum wait period in AutoLocking mode.

## Static Public Member Functions

static Bool | lockingDisabled ()
| Is table locking disabled (because AIPS_TABLE_NOLOCKING or table.nolocking is set)?

## Private Member Functions

void | init ()
| Set itsOption and itsReadLocking when needed.

## Private Attributes

LockOption | itsOption
Bool | itsReadLocking
uInt | itsMaxWait
double | itsInterval
Bool | itsIsDefaultLocking
Bool | itsIsDefaultInterval

## Detailed Description

Class to hold table lock options.

### Intended use:

Internal

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25
Test programs:
  tTable

### Prerequisite

- class Table
- class LockFile

### Synopsis

This class keeps the Table lock options. Currently these are the LockingOption and the inspection interval.

It also keeps the LockFile object used to do the actual locking/unlocking.

It is possible to disable locking by building casacore with -DAIPS_TABLE_NOLOCKING or by setting the aipsrc variable table.nolocking=true.

### Motivation

Encapsulate Table locking info.

Definition at line 66 of file TableLock.h.

## Member Enumeration Documentation

## LockOption

enum casacore::TableLock::LockOption

Define the possible table locking options.

They offer the user the possibility to lock and synchronize access to the table. A lot of locking degrades table performance; not only because acquiring/releasing locks takes time, but especially because table data has to be synchronized (thus written to disk) when a lock is released. Otherwise the other processes see data which is not up-to-date.

Building Casacore with -DTABLE_NOLOCKING or setting aipsrc variable table.nolocking=1 forces lock option NoLocking.

Enumerator
PermanentLocking | The table is permanently locked. A lock is set at the beginning and only released when the table is closed. A read lock is used when the table is opened for readonly; otherwise a write lock is used. This means that multiple readers are possible. The Table constructor exits with an exception when the lock cannot be acquired.
PermanentLockingWait | The same as above, but the table constructor waits until the lock gets available.
AutoLocking | The system takes care of acquiring/releasing locks. In principle it keeps the table locked, but from time to time (defined by the inspection interval) it is checked whether another process wants to access the table. If so, the lock is released and probably re-acquired later. This mode is the default mode.
UserLocking | The user is taking care of locking the table by means of the Table functions lock and unlock. In this way transaction processing can be implemented.
AutoNoReadLocking | The system takes care of acquiring/releasing locks. It is similar to AutoLocking, but no locks are needed for reading.
UserNoReadLocking | The user is taking care of locking the table by means of the Table functions lock and unlock. It is similar to UserLocking, but no locks are needed for reading.
NoLocking | Do not do any locking at all. This should be used with care because concurrent access might result in table corruption.
DefaultLocking | This is the default locking option. It means that AutoLocking will be used if the table is not opened yet. Otherwise the locking options of the PlainTable object already in use will be used.

Definition at line 79 of file TableLock.h.

## Constructor & Destructor Documentation

## TableLock() [1/3]

casacore::TableLock::TableLock | ( | LockOption | option = DefaultLocking | ) |

Construct with given option and interval.

The default LockOption is AutoLocking. In case of AutloLocking the inspection interval defines how often the table system checks if another process needs a lock on the table. It defaults to 5 seconds. The maxWait defines the maximum number of seconds the table system waits when acquiring a lock in AutoLocking mode. The default is 0 seconds meaning indefinitely.

References DefaultLocking, and option().

Referenced by merge(), operator=(), TableLock(), and casacore::TableLockData::TableLockData().

## TableLock() [2/3]

casacore::TableLock::TableLock | ( | LockOption | option,
|  | double | inspectionInterval,
|  | uInt | maxWait = 0 )

References maxWait(), and option().

## TableLock() [3/3]

casacore::TableLock::TableLock | ( | const TableLock & | that | ) |

Copy constructor.

References TableLock().

## Member Function Documentation

## init()

void casacore::TableLock::init | ( |  | ) |

private

Set itsOption and itsReadLocking when needed.

## interval()

double casacore::TableLock::interval | ( |  | ) | const

inline

Get the inspection interval.

Definition at line 198 of file TableLock.h.

References itsInterval.

## isPermanent()

Bool casacore::TableLock::isPermanent | ( |  | ) | const

inline

Is permanent locking used?

Definition at line 192 of file TableLock.h.

References itsOption, PermanentLocking, and PermanentLockingWait.

## lockingDisabled()

Bool casacore::TableLock::lockingDisabled | ( |  | ) |

static

Is table locking disabled (because AIPS_TABLE_NOLOCKING or table.nolocking is set)?

## maxWait()

uInt casacore::TableLock::maxWait | ( |  | ) | const

inline

Get the maximum wait period in AutoLocking mode.

Definition at line 203 of file TableLock.h.

References itsMaxWait.

Referenced by TableLock().

## merge()

void casacore::TableLock::merge | ( | const TableLock & | that | ) |

Merge that TableLock with this TableLock object by taking the maximum option and minimum inspection interval.

The option order (ascending) is UserLocking, AutoLocking, PermanentLocking. When an interval was defaulted, it is not taken into account. An option DefaultLocking is not taken into account.

References TableLock().

## operator=()

TableLock & casacore::TableLock::operator= | ( | const TableLock & | that | ) |

Assignment.

References TableLock().

## option()

TableLock::LockOption casacore::TableLock::option | ( |  | ) | const

inline

Get the locking option.

Definition at line 182 of file TableLock.h.

References itsOption.

Referenced by casacore::TableLockData::autoRelease(), TableLock(), and TableLock().

## readLocking()

Bool casacore::TableLock::readLocking | ( |  | ) | const

inline

Is read locking needed?

Definition at line 187 of file TableLock.h.

References itsReadLocking.

## Member Data Documentation

## itsInterval

double casacore::TableLock::itsInterval

private

Definition at line 171 of file TableLock.h.

Referenced by interval().

## itsIsDefaultInterval

Bool casacore::TableLock::itsIsDefaultInterval

private

Definition at line 173 of file TableLock.h.

## itsIsDefaultLocking

Bool casacore::TableLock::itsIsDefaultLocking

private

Definition at line 172 of file TableLock.h.

## itsMaxWait

uInt casacore::TableLock::itsMaxWait

private

Definition at line 170 of file TableLock.h.

Referenced by maxWait().

## itsOption

LockOption casacore::TableLock::itsOption

private

Definition at line 168 of file TableLock.h.

Referenced by isPermanent(), and option().

## itsReadLocking

Bool casacore::TableLock::itsReadLocking

private

Definition at line 169 of file TableLock.h.

Referenced by readLocking().

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

- tables/Tables/TableLock.h