PHP Класс malkusch\lock\mutex\Mutex

Автор: Markus Malkusch ([email protected])
Показать файл Открыть проект

Открытые методы

Метод Описание
check ( callable $check ) : DoubleCheckedLocking Performs a double-checked locking pattern.
synchronized ( callable $code ) : mixed Executes a block of code exclusively.

Описание методов

check() публичный Метод

Call {@link DoubleCheckedLocking::then()} on the returned object. Example: $mutex->check(function () use ($bankAccount, $amount) { return $bankAccount->getBalance() >= $amount; })->then(function () use ($bankAccount, $amount) { $bankAccount->withdraw($amount); });
public check ( callable $check ) : DoubleCheckedLocking
$check callable
Результат malkusch\lock\util\DoubleCheckedLocking The double-checked locking pattern.

synchronized() абстрактный публичный Метод

This method implements Java's synchronized semantic. I.e. this method waits until a lock could be acquired, executes the code exclusively and releases the lock. The code block may throw an exception. In this case the lock will be released as well.
abstract public synchronized ( callable $code ) : mixed
$code callable The synchronized execution block.
Результат mixed The return value of the execution block.