Runs the queue.
@param int $limit
@return int|void
352667
public function actionRun($limit = 0)
    {
        $version = $this->module->version;
        $this->stdout("\nPodium mail queue v{$version}\n");
        $this->stdout("------------------------------\n");

        $emails = $this->getNewBatch($limit);
        if (empty($emails)) {
            $this->stdout("No pending emails in the queue found.\n\n", Console::FG_GREEN);
            return self::EXIT_CODE_NORMAL;
        }

        $total = count($emails);
        $this->stdout(
            "\n$total pending "
                . ($total === 1 ? 'email' : 'emails')
                . " to be sent now:\n",
            Console::FG_YELLOW
        );

        $errors = false;
        foreach ($emails as $email) {
            if (!$this->process(
                    $email,
                    $this->module->podiumConfig->get('from_name'),
                    $this->module->podiumConfig->get('from_email'),
                    $this->module->podiumConfig->get('max_attempts')
                )) {
                $errors = true;
            }
        }

        if ($errors) {
            $this->stdout("\nBatch sent with errors.\n\n", Console::FG_RED);
        } else {
            $this->stdout("\nBatch sent successfully.\n\n", Console::FG_GREEN);
        }
        return self::EXIT_CODE_NORMAL;
    }
536281
public function tick()
    {
        $count = $this->queue->count();

        while ($count-- && $this->loop->isRunning())
        {
            $this->callback = $this->queue->dequeue();
            $callback = $this->callback; // without this proxy PHPStorm marks line as fatal error.
            $callback($this->loop);
        }
    }
756942
public function run() {
		$transactions = Transaction::get_runnable();

		foreach ($transactions as $transaction) {
			$transaction->lock();
			self::run_transaction($transaction);
			$transaction->unlock();
		}
	}
428572
public function run($requests)
    {
        $this->_queue   = $requests;
        $this->_status  = array_fill(0, $this->threads, false);
        $this->_retries = array_fill(0, $this->threads, 0);
        $this->processNext();
        parent::run();
    }
1021695
public function setLimit($limit)
    {
        if (!is_scalar($limit)) {
            $this->limit = self::DEFAULT_LIMIT;

            return $this;
        } else {
            $limit = (int)$limit;
        }

        if ($limit > self::MAX_LIMIT) {
            $this->limit = self::MAX_LIMIT;
        } elseif ($limit < 1) {
            $this->limit = self::DEFAULT_LIMIT;
        } else {
            $this->limit = $limit;
        }

        return $this;
    }
1287118
public function limit($limit, $offset = null)
    {
        if ($offset) {
            $this->getLimit()->setParams(array($limit, $offset));
        } else {
            $this->getLimit()->setParams(array($limit));
        }

        return $this;
    }
1354310
public function setLimit(int $limit, ?int $offset = null): self
    {
        $this->limit = $limit;
        if ($offset !== null) {
            $this->setOffset($offset);
        }

        return $this;
    }
1197495
public function limit($limit, $offset = null)
    {
        $this->_limit = $limit > 0 ? (int)$limit : null;
        $this->_offset = $offset > 0 ? (int)$offset : null;

        return $this;
    }
853676
public function limit($limit)
    {
        Assertion::integer($limit);
        Assertion::range($limit, 1, 50);

        $this->limit = $limit;

        return $this;
    }
1079486
public function withLimit(int $limit): self
    {
        $paginator = clone $this;
        $paginator->limit = $limit;

        return $paginator;
    }
342362
public function run()
    {
        // initialize infinite loop counter
        $redirects = 0;

        // create the request
        $requestParser = $this->getRequestParser();
        $request = $requestParser->createRequest();

        // start of the request loop
        do
        {
            // do the infinite loop check
            $this->checkRedirectLimit( $redirects );
            $continue = false;

            // run pre-routing filters
            $this->configuration->runPreRoutingFilters( $request );

            // create the router from the configuration
            $router = $this->getRouter( $request );

            // router creates routing information
            try
            {
                $routingInformation = $router->getRoutingInformation();
            }
            catch ( ezcMvcRouteNotFoundException $e )
            {
                $request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
                $continue = true;
                continue;
            }
            // here's the reason to override ezcMvcConfigurableDispatcher::run()
            catch ( ezpRouteMethodNotAllowedException $e )
            {
                $request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
                $continue = true;
                continue;
            }
            // end diff


            // run request filters
            $filterResult = $this->configuration->runRequestFilters( $routingInformation, $request );

            if ( $filterResult instanceof ezcMvcInternalRedirect )
            {
                $request = $filterResult->request;
                $continue = true;
                continue;
            }

            // create the controller
            $controller = $this->getController( $routingInformation, $request );

            // run the controller
            try
            {
                $result = $controller->createResult();
            }
            catch ( Exception $e )
            {
                $request = $this->getFatalRedirectRequest( $request, new ezcMvcResult, $e );
                $continue = true;
                continue;
            }

            if ( $result instanceof ezcMvcInternalRedirect )
            {
                $request = $result->request;
                $continue = true;
                continue;
            }
            if ( !$result instanceof ezcMvcResult )
            {
                throw new ezcMvcControllerException( "The action '{$routingInformation->action}' of controller '{$routingInformation->controllerClass}' did not return an ezcMvcResult object." );
            }

            $this->configuration->runResultFilters( $routingInformation, $request, $result );

            if ( $result->status !== 0 )
            {
                $response = new ezcMvcResponse;
                $response->status = $result->status;
            }
            else
            {
                // want the view manager to use my filters
                $view = $this->getView( $routingInformation, $request, $result );

                // create the response
                try
                {
                    $response = $view->createResponse();
                }
                catch ( Exception $e )
                {
                    $request = $this->getFatalRedirectRequest( $request, $result, $e );
                    $continue = true;
                    continue;
                }
            }
            $this->configuration->runResponseFilters( $routingInformation, $request, $result, $response );

            // create the response writer
            $responseWriter = $this->getResponseWriter( $routingInformation, $request, $result, $response );

            // handle the response
            $responseWriter->handleResponse();
        }
        while ( $continue );
    }
526392
public function limit($limit = null)
    {
        if (!func_num_args()) {
            return $this->_limit;
        }
        $this->_limit = $limit;
        return $this;
    }
378458
public function limit($limit)
    {
        $limit = (int)$limit;
        $limit < 1 && $limit = 1;
        return $this->add('limit', $limit);
    }
1084243
public function limit($limit)
    {
        if (null !== $limit) {
            if (!is_numeric($limit) || $limit != (int) $limit) {
                throw new \InvalidArgumentException('The limit is not valid.');
            }
            $limit = (int) $limit;
        }

        $this->limit = $limit;

        return $this;
    }
1359917
public function limit($limit)
    {
        if ($this->queryType !== self::QUERY_SELECT) {
            $this->exception = new QueryException("Limit can only be applied on SELECT mode!", 0, $this->exception);
            return $this;
        }
        if (! is_int($limit) || $limit < 0) {
            $this->exception = new QueryException("Limit value should be an positive integer!", 0, $this->exception);
            return $this;
        }
        $this->limitCount = intval($limit);

        return $this;
    }
788384
public function limit($limit, $offset = null)
    {
        $this->queryBuilder->setLimit($limit, $offset);
        return $this;
    }
76
public function addLimitOffset(int $limit, int $offset): void
    {
        if ($limit === 0 && $offset === 0) {
            return;
        }
        if ($limit === 0 && $offset <> 0) {
            return;
        }
        if ($offset === 0) {
            $this->statement .= ' LIMIT ' . $limit;
        } else {
            $this->statement .= sprintf(' LIMIT %d, %d', $offset, $limit);
        }
        $this->statement .= PHP_EOL;
    }