LockingStrategyInterface

Interface for locking methods

Table of Contents

Constants

LOCK_CAPABILITY_EXCLUSIVE  : mixed = 1
Exclusive locks can be acquired
LOCK_CAPABILITY_NOBLOCK  : mixed = 4
Do not block when acquiring the lock
LOCK_CAPABILITY_SHARED  : mixed = 2
Shared locks can be acquired

Methods

__construct()  : mixed
acquire()  : bool
Try to acquire a lock
destroy()  : mixed
Destroys the resource associated with the lock
getCapabilities()  : int
getPriority()  : int
isAcquired()  : bool
Get status of this lock
release()  : bool
Release the lock

Constants

LOCK_CAPABILITY_EXCLUSIVE

Exclusive locks can be acquired

public mixed LOCK_CAPABILITY_EXCLUSIVE = 1

LOCK_CAPABILITY_NOBLOCK

Do not block when acquiring the lock

public mixed LOCK_CAPABILITY_NOBLOCK = 4

LOCK_CAPABILITY_SHARED

Shared locks can be acquired

public mixed LOCK_CAPABILITY_SHARED = 2

Methods

__construct()

public __construct(string $subject) : mixed
Parameters
$subject : string

ID to identify this lock in the system

Tags
throws
LockCreateException

if the lock could not be created

acquire()

Try to acquire a lock

public acquire([int $mode = self::LOCK_CAPABILITY_EXCLUSIVE ]) : bool
Parameters
$mode : int = self::LOCK_CAPABILITY_EXCLUSIVE

LOCK_CAPABILITY_EXCLUSIVE or LOCK_CAPABILITY_SHARED

Tags
throws
LockAcquireException

if the lock could not be acquired

throws
LockAcquireWouldBlockException

if the acquire would have blocked and NOBLOCK was set

Return values
bool —

Returns TRUE if the lock was acquired successfully

destroy()

Destroys the resource associated with the lock

public destroy() : mixed

getCapabilities()

public static getCapabilities() : int
Return values
int —

LOCK_CAPABILITY_* elements combined with bit-wise OR

getPriority()

public static getPriority() : int
Return values
int —

Returns a priority for the method. 0 to 100, 100 is highest

isAcquired()

Get status of this lock

public isAcquired() : bool
Return values
bool —

Returns TRUE if lock is acquired by this locker, FALSE otherwise

release()

Release the lock

public release() : bool
Return values
bool —

Returns TRUE on success or FALSE on failure

On this page

Search results