GPhpThread - a heavy threads implementation in pure PHP - Documentation

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
see
GPhpThreadCriticalSection
see
GPhpThreadNotCloneableContainer
throws
GPhpThreadException

When improperly passed/configured a critical section or clone attempts are made.

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
throws
GPhpThreadException

Exception is thrown in case an uninitialized critical section is passed or the specified lock or unlock methods are missing.

__destruct()

Destructor. Immediately unlocks the passed critical section.

public final __destruct() : mixed

        
On this page

Search results