compute example

private \Closure $callbackWrapper;
    private array $computing = [];

    /** * Wraps the callback passed to ->get() in a callable. * * @return callable the previous callback wrapper */
    public function setCallbackWrapper(?callable $callbackWrapper): callable
    {
        if (!isset($this->callbackWrapper)) {
            $this->callbackWrapper = LockRegistry::compute(...);

            if (\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
                $this->setCallbackWrapper(null);
            }
        }

        if (null !== $callbackWrapper && !$callbackWrapper instanceof \Closure) {
            $callbackWrapper = $callbackWrapper(...);
        }

        $previousWrapper = $this->callbackWrapper;
        
Home | Imprint | This part of the site doesn't use cookies.