Stop buffer and put it in cache
@param float $timeout
@return $this
770448
public function stop(float $timeout = 0.0): self
    {
        if ($this->lastKey !== null) {
            $this->set($this->lastKey, ob_get_clean(), $timeout);
        }
        $this->lastKey = null;
        return $this;
    }
552406
public function setTimeout($timeout)
    {
        $this->timeout = $timeout;

        if($this->hasValidResource() && $this->timeout !== -1) {
            stream_set_timeout($this->resource, $timeout);
        }

        return $this;
    }
115638
public function setTimeout($timeout) {
            $this->timeout = $timeout;
            $this->process->setTimeout($this->timeout);
            return $this;
        }
150072
public function retry(int $times = 1, int $timeout = 0): Call
    {
        \assert('$times >= 1 && $timeout >= 0');
        \assert('$this->current !== null');
        if ($this->current !== null) {
            $this->catchers[$this->current][] = function (...$args) use ($times, $timeout) {
                static $lTimes;
                if ($lTimes === null) {
                    $lTimes = $times;
                }
                // the first end() is already invoked
                $lTimes--;
                if ($lTimes > 0) {
                    usleep($timeout);
                    return $this->end(...$args);
                }
                return null;
            };
        }
        return $this;
    }
1175389
public function setRecvTimeout($timeout)
    {
        $this->recvTimeoutSec_ = floor($timeout / 1000);
        $this->recvTimeoutUsec_ =
            ($timeout - ($this->recvTimeoutSec_ * 1000)) * 1000;
    }
300671
public function block($timeout, $callback = null)
    {
        $starting = time();

        while (! $this->acquire()) {
            if (time() - $timeout >= $starting) {
                throw new LimiterTimeoutException;
            }

            usleep(750 * 1000);
        }

        if (is_callable($callback)) {
            $callback();
        }

        return true;
    }
1368413
public function timeout(int $seconds): self
    {
        return tap($this, function () use ($seconds) {
            return $this->options = array_merge_recursive($this->options, [
                'timeout' => $seconds,
            ]);
        });
    }
1321183
public static <K, V> TimedCache<K, V> newTimedCache(long timeout){
		return new TimedCache<K, V>(timeout);
	}
301773
function setTimeout($seconds)
    {
        if (is_array($seconds))
            $seconds = implode('.', $seconds);

        $this->timeout = $seconds;
        return $this;
    }
233779
public function block($timeout, $callback = null)
    {
        $starting = time();

        $id = Str::random(20);

        while (! $slot = $this->acquire($id)) {
            if (time() - $timeout >= $starting) {
                throw new LimiterTimeoutException;
            }

            usleep(250 * 1000);
        }

        if (is_callable($callback)) {
            try {
                return tap($callback(), function () use ($slot, $id) {
                    $this->release($slot, $id);
                });
            } catch (Exception $exception) {
                $this->release($slot, $id);

                throw $exception;
            }
        }

        return true;
    }
228171
public function timeout($timeout)
    {
        if (null !== $timeout) {
            if (!is_numeric($timeout) || $timeout != (int) $timeout) {
                throw new \InvalidArgumentException('The timeout is not valid.');
            }
            $timeout = (int) $timeout;
        }

        $this->timeout = $timeout;

        return $this;
    }
1199810
public function lock($key, $timeout = self::EXPIRE): bool
    {
        $wait = 20000;
        $totalWait = 0;
        $time = $timeout * 1000000;
        $key = self::PREFIX . $key;

        while ($totalWait < $time && false === $this->mem->add($key, 1, $timeout)) {
            usleep($wait);
            $totalWait += $wait;
        }

        if ($totalWait >= $time) {
            throw new \RuntimeException('cannot get lock for waiting ' . $timeout . 's.', __LINE__);
        }

        return true;
    }
912969
public function connect($timeout = self::TIMEOUT, $test = false)
    {
        if ($this->socket) {
            return $this;
        }

        $host = $this->host;

        if ($this->ssl) {
            $host = 'ssl://' . $host;
        }

        $errno  =  0;
        $errstr = '';

        $this->socket = @fsockopen($host, $this->port, $errno, $errstr, $timeout);

        if (!$this->socket) {
            //throw exception
            Exception::instance()
                ->setMessage(Exception::SERVER_ERROR)
                ->addVariable($host.':'.$this->port)
                ->trigger();
        }

        if (strpos($this->getLine(), '* OK') === false) {
            $this->disconnect();
            //throw exception
            Exception::instance()
                ->setMessage(Exception::SERVER_ERROR)
                ->addVariable($host.':'.$this->port)
                ->trigger();
        }

        if ($this->tls) {
            $this->send('STARTTLS');
            if (!stream_socket_enable_crypto($this->socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
                $this->disconnect();
                //throw exception
                Exception::instance()
                ->setMessage(Exception::TLS_ERROR)
                ->addVariable($host.':'.$this->port)
                ->trigger();
            }
        }

        if ($test) {
            fclose($this->socket);

            $this->socket = null;
            return $this;
        }

        //login
        $result = $this->call('LOGIN', $this->escape($this->username, $this->password));

        if (!is_array($result) || strpos(implode(' ', $result), 'OK') === false) {
            $this->disconnect();
            //throw exception
            Exception::instance(Exception::LOGIN_ERROR)->trigger();
        }

        return $this;
    }
752571
public function run($timeout = -1, $blocking = self::NON_BLOCKING)
    {
        if ($this->running) {
            throw new RuntimeException('Process already running.');
        }

        try {
            $this->exec(false, $blocking);

            $this->wait($timeout);
        } catch (ProcessException $ex) {
            throw $ex;
        } catch (Exception $ex) {
            $this->cleanup();
            throw new ProcessException('Unknown process exception.', $this, $ex);
        }

        return $this;
    }
1202132
public static function setTimeout($timeout)
	{
		self::$options[CURLOPT_TIMEOUT] = $timeout;
		self::$options[CURLOPT_CONNECTTIMEOUT] = $timeout;
	}
91740
public function setReadTimeout(int $timeout)
    {
        if ($timeout < -1) {
            throw new RedisException('Timeout values less than -1 are not accepted.');
        }
        $this->readTimeout = $timeout;
        if ($this->connected) {
            $timeout = $timeout <= 0 ? 315360000 : $timeout; // Ten-year timeout
            \stream_set_blocking($this->redis, true);
            \stream_set_timeout($this->redis, (int) \floor($timeout), ($timeout - \floor($timeout)) * 1000000);
        }

        return $this;
    }
1030808
protected function _terminate($timeout = 10, $signal = /* SIGTERM */ 15) {
		foreach ($this->_getPidRecursive($this->getPid()) as $pid) {
			posix_kill($pid, $signal);
		}
		parent::stop($timeout, $signal);
	}