# class Lockable | Abstract interface for lockable objects. More...
Contains pure virtuals
Full name | `TelEngine::Lockable`
Definition | `#include <yateclass.h>`
Inherited by | AnalogLine, AnalogLineGroup, ChanAssistList, ClientAccount, ClientAccountList, ClientDriver, DataSource, Driver, IAXEngine, IAXMetaTrunkFrame, IAXTransaction, ISDNIUAClient, ISDNQ931, ISDNQ931Call, ISDNQ931CallMonitor, ISDNQ931Monitor, JBClientEngine, JBClientStream, JBClusterStream, JBEngine, JBEntityCapsList, JBServerEngine, JBServerStream, JBStream, JBStreamSet, JBStreamSetList, JBStreamSetProcessor, JBStreamSetReceive, JGEngine, JGSession, JGSession0, JGSession1, MGCPEndpoint, MGCPEngine, MGCPTransaction, MessageDispatcher, MessageQueue, Module, MultiRouter, Mutex, RTPGroup, RTPSession, SCCPManagement, SDPParser, SIGAdaptClient, SIGAdaptServer, SIGAdaptation, SIPEngine, SS7AnsiSccpManagement, SS7BICC, SS7ISUP, SS7ISUPCall, SS7ItuSccpManagement, SS7M2UAClient, SS7MTP2, SS7MTP3, SS7Management, SS7Route, SS7Router, SS7SCCP, SS7TCAPTransaction, SS7TCAPTransactionANSI, SS7TCAPTransactionITU, SS7TUP, SS7Testing, SccpLocalSubsystem, SccpRemote, ScriptRun, Semaphore, SharedVars, SignallingCall, SignallingCallControl, SignallingCircuitGroup, SignallingEngine, ThreadedSource, UDPTLSession
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- virtual ~Lockable ()
- virtual bool lock (long maxwait = -1)
- virtual bool unlock ()
- virtual bool locked () const
- virtual bool check (long maxwait = -1)
- virtual bool unlockAll ()

#### Public Static Methods

- static void wait (unsigned long maxwait)
- static unsigned long wait ()
- static void startUsingNow ()
- static void enableSafety (bool safe = true)

## Detailed Description

An abstract base class for implementing lockable objects

~Lockable () | ### ~Lockable

[virtual]

Destructor

bool lock (long maxwait = -1) | ### lock

[pure virtual]

Attempt to lock the object and eventually wait for it

Parameters:

maxwait | Time in microseconds to wait, -1 wait forever

Returns: True if successfully locked, false on failure

bool unlock () | ### unlock

[pure virtual]

Unlock the object, does never wait

Returns: True if successfully unlocked the object

bool locked () | ### locked

[const pure virtual]

Check if the object is currently locked - as it's asynchronous it guarantees nothing if other thread changes the status

Returns: True if the object was locked when the function was called

bool check (long maxwait = -1) | ### check

[virtual]

Check if the object is unlocked (try to lock and unlock it)

Parameters:

maxwait | Time in microseconds to wait, -1 to wait forever

Returns: True if successfully locked and unlocked, false on failure

bool unlockAll () | ### unlockAll

[virtual]

Fully unlock the object, even if it was previously multiple locked. There is no guarantee about the object status after the function returns. This function should be used only if you understand it very well

Returns: True if the object was fully unlocked

void wait (unsigned long maxwait) | ### wait

[static]

Set a maximum wait time for debugging purposes

Parameters:

maxwait | Maximum time in microseconds to wait for any lockable object when no time limit was requested, zero to disable limit

unsigned long wait () | ### wait

[static]

Get the maximum wait time used for debugging purposes

Returns: Maximum time in microseconds, zero if no maximum is set

void startUsingNow () | ### startUsingNow

[static]

Start actually using lockables, for platforms where these objects are not usable in global object constructors. This method must be called at least once somewhere from main() but before creating any threads and without holding any object locked.

void enableSafety (bool safe = true) | ### enableSafety

[static]

Enable some safety and sanity check features. This provides a safer code and easier locking debugging at the price of performance penalty. This method must be called early and not changed after initialization

Parameters:

safe | True to enable locking safety measures, false to disable

Generated by: paulc on bussard on Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.