从当前列表尾部获取一个元素,并移动到目标列表头部,如果没有则等待
@param $target string 目标列表键名
@param int $timeout 超时秒数,0表示无限阻塞
@return string 被移动的元素值
501557
public function moveWait(string $target, int $timeout = 0): string
    {
        return $this->handle->brpoplpush($this->name, $target, $timeout);
    }
1265529
public function timeout($timeout = null, $connectTimeout = null)
    {
        if(null !== $timeout)
        {
            $this->timeout = $timeout;
        }
        if(null !== $connectTimeout)
        {
            $this->connectTimeout = $connectTimeout;
        }
        return $this;
    }
1167898
public function identifyFromUrl( $url, $timeout = 5 )
	{
		Net_CURL::setTimeOut( $timeout );
		$xml	= Net_Reader::readUrl( $url );
		return $this->identify( $xml );
	}
334941
protected function getIndex($target){
        if(is_string($target)){
            if(!class_exists($target) && !interface_exists($target)){
                throw new \InvalidArgumentException(
                    "Searche target must be specified by class name or"
                    . " interface name."
                );
            }

            foreach($this->queue as $index => $middleware){
                if(
                    get_class($middleware) === $target
                    || is_subclass_of($middleware, $target)
                ){
                    return $index;
                }
            }
        }elseif(is_object($target)){
            if(!$target instanceof MiddlewareInterface){
                $class  = MiddlewareInterface::class;
                throw new \InvalidArgumentException(
                    "Searche target must be an instance of a class that"
                    . " implements {$class}."
                );
            }

            foreach($this->queue as $index => $middleware){
                if($target === $middleware){
                    return $index;
                }
            }
        }else{
            throw new \InvalidArgumentException(
                "The searche target must be specified by object or string."
            );
        }

        return null;
    }
193988
public function retry($timeout, $callback)
    {
        $start = time();

        beginning:

        if ($output = $callback()) {
            return $output;
        }

        if (time() - $start < $timeout) {
            sleep(5);

            goto beginning;
        }

        throw new TimeoutException($output);
    }
408726
public function delete($key, $timeout = 0) {
		return $this->cache->delete($this->prefix.$key, $timeout);
	}
188223
public function setTimeout($timeout)
    {
        $timeout = is_scalar($timeout) ? (int) $timeout : 0;

        return $timeout < 1
            ? $this->timeout
            : $this->timeout = $timeout;
    }
827146
public function iterate($timeout)
    {

        // call parent method and sleep for the default timeout
        parent::iterate($timeout);

        // iterate over the timer tasks that has to be executed
        foreach ($this->tasksToExecute as $taskId => $timerTaskWrapper) {
            // this should never happen
            if (!$timerTaskWrapper instanceof \stdClass) {
                // log an error message because we task wrapper has wrong type
                \error(sprintf('Timer-Task-Wrapper %s has wrong type %s', $taskId, get_class($timerTaskWrapper)));
                // we didn't foud a timer task ignore this
                continue;
            }

            // query if the task has to be executed now
            if ($timerTaskWrapper->executeAt < microtime(true)) {
                // load the timer task wrapper we want to execute
                if ($pk = $this->scheduledTimers[$timerId = $timerTaskWrapper->timerId]) {
                    // load the timer service registry
                    $timerServiceRegistry = $this->getApplication()->search(TimerServiceContextInterface::IDENTIFIER);

                    // lookup the timer from the timer service
                    $timer = $timerServiceRegistry->lookup($pk)->getTimers()->get($timerId);

                    // create and execute the timer task
                    $this->timerTasks[$taskId] = $timer->getTimerTask($this->getApplication());

                    // remove the key from the list of tasks to be executed
                    unset($this->tasksToExecute[$taskId]);

                } else {
                    // log an error message because we can't find the timer instance
                    \error(sprintf('Can\'t find timer %s to create timer task %s', $timerTaskWrapper->timerId, $taskId));
                }
            }
        }

        // collect the garbage (finished timer task jobs)
        $this->collectGarbage();

        // profile the size of the timer tasks to be executed
        if ($this->profileLogger) {
            $this->profileLogger->debug(
                sprintf('Processed timer service executor, executing %d timer tasks', sizeof($this->tasksToExecute))
            );
        }
    }
1305015
protected function timeoutForJob($job, $timeout)
    {
        return $job && !is_null($job->timeout()) ? $job->timeout() : $timeout;
    }
112388
public function waitForAlert($timeout = 60)
	{
		$result = FALSE;
		$i = 0;
		do
		{
			sleep(1);
			try
			{
				$result = $this->alertText();
			}
			catch (\RuntimeException $e)
			{
				;
			}
		} while (++$i < $timeout && $result === FALSE);
		return $result;
	}
1094715
public function receive($timeout = 0)
    {
        $startAt = microtime(true);

        while (true) {
            $message = $this->receiveMessage();

            if ($message) {
                return $message;
            }

            if ($timeout && (microtime(true) - $startAt) >= $timeout) {
                return;
            }

            usleep($this->pollingInterval);

            if ($timeout && (microtime(true) - $startAt) >= $timeout) {
                return;
            }
        }
    }
55431
protected function findTargetFilename($target)
    {
        //If the file already exists, adds a numeric suffix
        if (file_exists($target)) {
            $dirname = dirname($target) . DS;
            $filename = pathinfo($target, PATHINFO_FILENAME);
            $extension = pathinfo($target, PATHINFO_EXTENSION);

            //Initial tmp name
            $tmp = $dirname . $filename;

            for ($i = 1;; $i++) {
                $target = $tmp . '_' . $i;

                if ($extension) {
                    $target .= '.' . $extension;
                }

                if (!file_exists($target)) {
                    break;
                }
            }
        }

        return $target;
    }
266529
public function do_pop($topic, $timeout = PHP_INT_MAX)
    {
        $redis = is_object($this->_redis) ? $this->_redis : $this->_getRedis();
        if (!isset($this->_topicKeys[$topic])) {
            $keys = [];
            foreach ($this->_priorities as $priority) {
                $keys[] = $this->_prefix . $topic . ':' . $priority;
            }

            $this->_topicKeys[$topic] = $keys;
        }
        if ($timeout === 0) {
            foreach ($this->_topicKeys[$topic] as $key) {
                $r = $redis->rPop($key);
                if ($r !== false) {
                    return $r;
                }
            }

            return false;
        } else {
            $r = $redis->brPop($this->_topicKeys[$topic], $timeout);
            return isset($r[1]) ? $r[1] : false;
        }
    }
1226270
public function setConnectTimeout($timeout)
    {
        assert(is_int($timeout));
        assert($timeout >= 0);
        $this->_timeout = $timeout;

        return $this;
    }
394092
public function waitForEmail($timeout = 5)
    {
        $condition = function () {
            return !empty($this->fetchLastMessage());
        };

        $message = sprintf('Waited for %d secs but no email has arrived', $timeout);

        $this->wait($timeout)->until($condition, $message);
    }
293684
protected static function file_get_contents($url, $timeout = 10)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        if (substr($url, 0, 8) === 'https://') {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        }
        curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $content = curl_exec($ch);
        curl_close($ch);
        if (false === $content) {
            throw new \RuntimeException('\\PhpSimpleCas\\PhpCas::file_get_contents: curl_exec failed. CURL info: ' . curl_getinfo($ch));
        }
        return $content;
    }
1119902
public function blpop($keys, $timeout) {
        $keys = (array)$keys;
        return $this->returnCommand(['BLPOP'], $keys, [$keys, $timeout], ResponseParser::PARSE_ASSOC_ARRAY);
    }