GPhpThreadLockGuard
in package
implements
Serializable
A wrapper providing RAII mechanism for locking and unlocking purposes of critical section objects or similar, which also accounts for the thread from which it has been created.
Tags
Table of Contents
Interfaces
- Serializable
Properties
- $criticalSectionObj : object
- $unlockMethod : string
- $unlockMethodsParams : string
- $unlockOnceProtector : GPhpThreadNotClonableContainer
Methods
- __construct() : mixed
- Constructor. Immediately locks the passed critical section.
- __destruct() : mixed
- Destructor. Immediately unlocks the passed critical section.
Properties
$criticalSectionObj
private
object
$criticalSectionObj
= \NULL
The critical section that will be un/locked. REFERENCE type.
$unlockMethod
private
string
$unlockMethod
= 'unlock'
The unlock method name of the critical section that will be called during an unlock.
$unlockMethodsParams
private
string
$unlockMethodsParams
= array()
The parameters passed to the critical section's unlock method during an unlock.
$unlockOnceProtector
private
GPhpThreadNotClonableContainer
$unlockOnceProtector
= \NULL
Used to prevent unlocking of the same critical section from multiple heavy threads.
Methods
__construct()
Constructor. Immediately locks the passed critical section.
public
final __construct(object &$criticalSectionObj[, string $lockMethod = 'lock' ][, array<string|int, mixed> $lockMethodParams = array() ][, string $unlockMethod = 'unlock' ][, array<string|int, mixed> $unlockMethodsParams = array() ]) : mixed
Parameters
- $criticalSectionObj : object
-
An initialized critical section object or similar. A REFERENCE type.
- $lockMethod : string = 'lock'
-
The name of the $criticalSectionObj's lock method that will be called.
- $lockMethodParams : array<string|int, mixed> = array()
-
Parameter that will be passed to the lock method of $criticalSectionObj.
- $unlockMethod : string = 'unlock'
-
The name of the $criticalSectionObj's unlock method that will be called.
- $unlockMethodsParams : array<string|int, mixed> = array()
-
Parameter that will be passed to the unlock method of $criticalSectionObj.
Tags
__destruct()
Destructor. Immediately unlocks the passed critical section.
public
final __destruct() : mixed