Attempt to acquire the lock.

@param  callable|null  $callback
@return mixed
327198
public function get($callback = null)
    {
        $result = $this->acquire();

        if ($result && is_callable($callback)) {
            try {
                return $callback();
            } finally {
                $this->release();
            }
        }

        return $result;
    }
994845
protected static function callback($callback)
    {
        if( is_string($callback) && ! is_callable($callback) )
        {
            return self::controllerCallback($callback);
        }

        return $callback;
    }
431933
public function callback($callback)
    {
        $t = $this;
        $args = array_slice(func_get_args(),1);

        // use an event handler to dispatch to the callback
        $this->_events->register('startTransaction', function($event, $connection) use ($t, $callback, $args) {
            $t->results []= call_user_func_array($callback, $args);
        });

        return $this;
    }
219077
public function min(?callable $callback = null)
    {
        return $this->reduce(function ($result, $value, $key) use ($callback) {
            if ($callback !== null) {
                $value = $callback($value, $key);
            }

            return ($result === null) || $value < $result ? $value : $result;
        });
    }
1115302
public static function make(\Closure $callback = null)
    {
        self::$instance = new static();

        if ($callback instanceof \Closure) {
            return $callback(self::$instance);
        }

        return self::$instance;
    }
490030
public function transactional($callback)
    {
        $n = 0;
        $em = $this->doctrine->getManager();
        $em->getConnection()->beginTransaction();
        $callback($n);
        $em->getConnection()->commit();
        return $n;
    }
248693
public function call(Closure $callback = null, $caller = null)
    {
        if ($callback instanceof Closure) {
            // Make dependency injection possible
            $parameters = $this->resolveMethodDependencies(
                [$caller], new ReflectionFunction($callback)
            );
            call_user_func_array($callback, $parameters);
        }

        return $caller;
    }
321117
public function sort(callable $callback = null) : Queue
    {
        $values = $this->_sort($callback);
        $this->setValues($values);
        return $this;
    }
719772
public function transaction(Closure $callback, $attempts = 1)
    {
        for ($currentAttempt = 1; $currentAttempt <= $attempts; ++$currentAttempt) {
            $this->beginTransaction();

            // We'll simply execute the given callback within a try / catch block and if we
            // catch any exception we can rollback this transaction so that none of this
            // gets actually persisted to a database or stored in a permanent fashion.
            try {
                return tap($callback($this), function ($result) {
                    $this->commit();
                });
            }

            // If we catch an exception we'll rollback this transaction and try again if we
            // are not out of attempts. If we are out of attempts we will just throw the
            // exception back out and let the developer handle an uncaught exceptions.
            catch (Exception $e) {
                $this->handleTransactionException(
                    $e,
                    $currentAttempt,
                    $attempts
                );
            } catch (Throwable $e) {
                $this->rollBack();

                throw $e;
            }
        }
    }
1238081
public function filter($callback = null)
    {
        $test = array_filter($this->data, $callback);
        $clone = clone $this;
        return $clone->reset($test);
    }
1110130
public function map(callable $callback = null)
	{
		return $callback ? array_map($callback, $this->list) : $this->list;
	}
277875
public function extract(callable $callback = null)
    {

        if ($callback === null) {
            $result = $this->result->toArray();
        }
        else {
            $result = $callback($this->result->toArray());
        }

        return $result;

    }
676289
public function then(callable $callback, callable $failure = null)
    {
        try {
            return (new ConcurrencyLimiter(
                $this->connection, $this->name, $this->maxLocks, $this->releaseAfter
            ))->block($this->timeout, $callback);
        } catch (LimiterTimeoutException $e) {
            if ($failure) {
                return $failure($e);
            }

            throw $e;
        }
    }
1263130
public function find(callable $callback, $keepKey = false, $offset = null, $limit = null)
    {
        return $this->bindNewInstance(Arr::find($this->convertArray($this), $callback, $keepKey, $offset, $limit));
    }
360062
public static function spy(callable $callback = null): SpyVerifier
    {
        $container = self::$globals::$container;

        return $container->spyVerifierFactory->createFromCallback($callback);
    }
181784
public function resetCallBack(callable $callBack = null)
    {
        $this->callBack = null;
        $this->callBack = $callBack;
        return $this;
    }
491790
public function tryUntil($callback)
    {
        try {
            return call_user_func_array($this->process, $this->args);
        } catch (\Exception $e) {
            if (in_array(get_class($e), $this->allowedExceptions)) {
                throw $e;
            }
        }

        $this->logger->warning(sprintf('[%s] Waiting until callback return a success', $this->logInfos['callable']));

        $startTime = time();
        $retry = 1;

        for (;;) {
            if ($callback instanceof YoloInterface) {
                $available = $callback->isAvailable();
            } else {
                $available = call_user_func($callback);
            }

            if (true === $available) {
                try {
                    return call_user_func_array($this->process, $this->args);
                } catch (\Exception $e) {
                    $this->logger->warning(sprintf('[%s] Can\'t perform action [%s/%s]', $this->logInfos['callable'], $retry, $this->maxRetry));

                    if (in_array(get_class($e), $this->allowedExceptions)) {
                        throw $e;
                    }

                    ++$retry;
                }

                if ($retry >= $this->maxRetry) {
                    $this->logger->error(sprintf('[%s] retry has failed, aborting [%s/%s]', $this->logInfos['callable'], $retry, $this->maxRetry));

                    $retryException = new YoloException('', 0, $e);
                    $retryException->setRetry($this->maxRetry);
                    $retryException->setTimeout($this->timeout);
                    throw $retryException;
                }
            } else {
                $this->logger->warning(sprintf('[%s] Can\'t perform action, waiting next tick', $this->logInfos['callable']));
            }

            if ($this->timeout > 0 && (time() - $startTime) >= $this->timeout) {
                $retryException = new YoloException('Timed out');
                $retryException->setRetry($this->maxRetry);
                $retryException->setTimeout($this->timeout);

                throw $retryException;
            }

            sleep(1);
        }
    }