class Locker

Properties

static protected Channel> $channels

Methods

static bool
lock(string $key, float $timeout = -1)

Acquire the lock for the given key, or wait until its owner releases it.

static void
unlock(string $key)

Release the lock for the given key.

static void
flushState()

Flush all static state.

Details

at line 31
static bool lock(string $key, float $timeout = -1)

Acquire the lock for the given key, or wait until its owner releases it.

Returns true when the caller becomes the owner, which must release the lock in a finally block. Returns false once the owner has released it. A waiter then re-checks the shared result and, when the owner left none, calls lock() again, so one waiter becomes the next owner instead of all repeating the work.

Parameters

string $key
float $timeout

Seconds to wait for the owner (values less than or equal to zero wait indefinitely)

Return Value

bool

Exceptions

WaitTimeoutException
CanceledException

at line 56
static void unlock(string $key)

Release the lock for the given key.

Parameters

string $key

Return Value

void

at line 68
static void flushState()

Flush all static state.

Return Value

void