Core/src/Lock/LockTrait.php
public function synchronize(callable $func, array $options = [])
    {
        $result = null;
        $exception = null;

        if ($this->acquire($options)) {
            try {
                $result = $func();
            } catch (\Exception $ex) {
                $exception = $ex;
            }
            $this->release();
        }

        if ($exception) {
            throw $exception;
        }

        return $result;
    }
public function synchronize(callable $func, array $options = [])
    {
        $result = null;
        $exception = null;

        if ($this->acquire($options)) {
            try {
                $result = $func();
            } catch (\Exception $ex) {
                $exception = $ex;
            }
            $this->release();
        }

        if ($exception) {
            throw $exception;
        }

        return $result;
    }
public function synchronize ( callable $ func , array $ options = [ ] ) { $ result = null ; $ exception = null ; if ( $ this -> acquire ( $ options ) ) { try { $ result = $ func ( ) ; } catch ( \ Exception $ ex ) { $ exception = $ ex ; } $ this -> release ( ) ; } if ( $ exception ) { throw $ exception ; } return $ result ; }
Execute a callable within a lock. If an exception is caught during
execution of the callable the lock will first be released before throwing
it.

@param callable $func The callable to execute.
@param array $options [optional] {
Configuration options.

@type bool $blocking Whether the process should block while waiting
to acquire the lock. **Defaults to** true.
}
@return mixed
Execute a callable within a lock . If an exception is caught during execution of the callable the lock will first be released before throwing it .