PHP Class malkusch\lock\util\DoubleCheckedLocking

You should not instantiate this class directly. Use {@link Mutex::check()}.
Author: Markus Malkusch ([email protected])
Show file Open project: malkusch/lock Class Usage Examples

Public Methods

Method Description
__construct ( Mutex $mutex ) Sets the mutex.
setCheck ( callable $check ) Sets the check.
then ( callable $code ) Executes a code only if a check is true.

Method Details

__construct() public method

Sets the mutex.
public __construct ( Mutex $mutex )
$mutex malkusch\lock\mutex\Mutex The mutex.

setCheck() public method

Sets the check.
public setCheck ( callable $check )
$check callable The check.

then() public method

Both the check and the code execution are locked by a mutex. Only if the check fails the method returns before acquiring a lock.
public then ( callable $code )
$code callable The locked code.