SemaphoreLockStrategy implements LockingStrategyInterface uses BlockSerializationTrait

Semaphore locking

Table of Contents

Interfaces

LockingStrategyInterface
Interface for locking methods

Constants

DEFAULT_PRIORITY  = 25
FILE_LOCK_FOLDER  = 'lock/'

Properties

$filePath  : string
$id  : int
$isAcquired  : bool
$resource  : resource|SysvSemaphore|null

Methods

__construct()  : mixed
__destruct()  : mixed
Destructor
__wakeup()  : mixed
Deny object deserialization.
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

DEFAULT_PRIORITY

public mixed DEFAULT_PRIORITY = 25

FILE_LOCK_FOLDER

public mixed FILE_LOCK_FOLDER = 'lock/'

Properties

$id

protected int $id

Identifier used for this lock

$isAcquired

protected bool $isAcquired = false

TRUE if lock is acquired

$resource

protected resource|SysvSemaphore|null $resource

Semaphore Resource used for this lock

Methods

__construct()

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

ID to identify this lock in the system

Tags
throws
LockCreateException

__destruct()

Destructor

public __destruct() : mixed

__wakeup()

Deny object deserialization.

public __wakeup() : mixed

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

Tags
throws
LockAcquireException

if a semaphore could not be retrieved

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