Returns a Task that, when started, starts a timer of duration 'timeoutDuration' and awaits the passed SemiAwaitable (operation).
Synopsis
Declared in <folly/coro/Timeout.h>
template<
typename SemiAwaitable,
typename Duration,
typename TimekeeperPtr = std::nullptr_t>
/* implementation-defined */
timeoutNoDiscard(
SemiAwaitable semiAwaitable,
Duration timeoutDuration,
TimekeeperPtr tk = nullptr);
Description
The returned result is always that of the operation. In other words the result is never discarded, in contrast with timeout.
If the timeout duration elapses before the operation completes, the result should and typically will reflect cancellation (e.g. OperationCancelled) but this depends on how the operation responds (as cancellation is cooperative).
To disambiguate between cancellation and timeout, callers can inspect their own cancellation token.
IMPORTANT: This function has no effect if the passed operation does not respond to cancellation. The operation passed as the first argument must be able to respond to a request for cancellation on the CancellationToken injected to it via folly::coro::co_withCancellation in a timely manner for the timeout to work as expected.
If a timekeeper is provided then uses that timekeeper to start the timer, otherwise uses the process' default TimeKeeper if 'tk' is null.
Return Value
A task that always completes with the operation's result.
Parameters
Name |
Description |
semiAwaitable |
The operation to await under the timeout. |
timeoutDuration |
The duration after which the timer fires. |
tk |
The timekeeper used to start the timer, or null for the default. |
Created with MrDocs