malkusch\lock\util\DoubleCheckedLocking::then PHP Метод

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

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.
    public function then(callable $code)
    {
        if (!call_user_func($this->check)) {
            return;
        }
        $this->mutex->synchronized(function () use($code) {
            if (call_user_func($this->check)) {
                call_user_func($code);
            }
        });
    }