Deletes the message.
@param float|int  $timeout  An integer or float as timeout in seconds, after which the message gets deleted.
@param string     $reason
@return \React\Promise\ExtendedPromiseInterface
194695
function delete($timeout = 0, string $reason = '') {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) use ($timeout, $reason) {
            if($timeout > 0) {
                $this->client->addTimer($timeout, function () use ($reason, $resolve, $reject) {
                    $this->delete(0, $reason)->done($resolve, $reject);
                });
            } else {
                $this->client->apimanager()->endpoints->channel->deleteMessage($this->channel->getId(), $this->id, $reason)->done(function () use ($resolve) {
                    $resolve();
                }, $reject);
            }
        }));
    }
1374540
public function deactivate($reason = 'other', $explanation = '')
    {
        $userId = $this->id();

        if ($userId === null) {
            return false;
        }

        $request = [
            'user_id'     => $userId,
            'reason'      => $reason,
            'explanation' => $explanation,
        ];

        return $this->post(UrlBuilder::RESOURCE_DEACTIVATE_ACCOUNT, $request);
    }
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;
    }
1202132
public static function setTimeout($timeout)
	{
		self::$options[CURLOPT_TIMEOUT] = $timeout;
		self::$options[CURLOPT_CONNECTTIMEOUT] = $timeout;
	}
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;
            }
        }
    }
290361
public function recover($timeout = 900): void
    {
        $timeoutDate = new \DateTime();
        $timeoutDate->modify(sprintf('-%s seconds', $timeout));

        $str = sprintf('UPDATE %s se SET se.sentAt = null, se.status = :waitStatus, se.statusMessage = null WHERE se.status = :failedStatus AND se.sentAt <= :timeoutDate', $this->getClassName());
        $query = $this->getEntityManager()->createQuery($str)
            ->setParameter('waitStatus', SpoolEmailStatus::STATUS_WAITING)
            ->setParameter('failedStatus', SpoolEmailStatus::STATUS_FAILED)
            ->setParameter('timeoutDate', $timeoutDate)
        ;

        $query->execute();
    }
224357
public function setRequestTimeout($timeout)
    {
        if (!is_int($timeout) || $timeout < 0) {
            throw new Exception("Invalid value supplied for request timeout: $timeout");
        }

        $this->requestTimeout = $timeout;
        return $this;
    }
1190
private function getTimeout(): ?float
    {
        if (! is_numeric($this->option('timeout'))) {
            throw new \InvalidArgumentException('The timeout value must be a number.');
        }

        $timeout = (float) $this->option('timeout');

        return $timeout > 0 ? $timeout : null;
    }
297662
public function recover($timeout = 900)
    {
        foreach (new DirectoryIterator($this->path) as $file) {
            $file = $file->getRealPath();

            if ('.message.sending' == substr($file, -16)) {
                $lockedtime = filectime($file);
                if ((time() - $lockedtime) > $timeout) {
                    rename($file, substr($file, 0, -8));
                }
            }
        }
    }
1175389
public function setRecvTimeout($timeout)
    {
        $this->recvTimeoutSec_ = floor($timeout / 1000);
        $this->recvTimeoutUsec_ =
            ($timeout - ($this->recvTimeoutSec_ * 1000)) * 1000;
    }
918325
public function stop($remove = false, $timeout = 0)
    {
        if (!isset($this->actions['stop'])) {
            throw new InvalidActionException(sprintf('Impossible to stop the container "%s" (current state "%s").', $this->id, $this->state));
        }

        $this->client->post($this->actions['stop'], array(
            'remove' => $remove,
            'timeout' => $timeout
        ));
    }
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);
    }
552406
public function setTimeout($timeout)
    {
        $this->timeout = $timeout;

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

        return $this;
    }
68795
public function destroy($reason)
    {
        $this->id = null;
        $this->lifetime = 0;
        $this->lastActivityTimestamp = 0;
        $this->maximumAge = -1;
    }
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;
    }
1030808
protected function _terminate($timeout = 10, $signal = /* SIGTERM */ 15) {
		foreach ($this->_getPidRecursive($this->getPid()) as $pid) {
			posix_kill($pid, $signal);
		}
		parent::stop($timeout, $signal);
	}
1008161
function delete(string $reason = '') {
        return (new \React\Promise\Promise(function (callable $resolve, callable $reject) use ($reason) {
            $this->client->apimanager()->endpoints->channel->deleteChannelPermission($this->channel->getId(), $this->id, $reason)->then(function () use ($resolve) {
                $resolve();
            }, $reject);
        }));
    }