stlab 2.4.0
Modern, modular C++ algorithms, data structures, and concurrency primitives
Loading...
Searching...
No Matches

Detailed Description

Blocking wait helpers for futures (await, etc.).

Functions

template<class F>
auto stlab::invoke_waiting (F &&f)
 Assumes f will block waiting; on the portable task system, wakes the pool or adds a worker (up to the limit) before calling f. Terminates without invoking f when the core uses cooperative threadless execution.
template<class T>
auto stlab::await (future< T > &&x) -> T
 Synchronously wait for the result x. If x resolves as an exception, the exception is rethrown. When using the portable task system, an additional thread is added to the pool if no threads are available and the maximum number of threads has not been reached. In cooperative threadless execution, terminates if x is not already ready.
template<class T>
auto stlab::await (const future< T > &x) -> T
 Equivalent to await(copy(x)).
template<class T>
auto stlab::await_for (future< T > &&x, const std::chrono::nanoseconds &timeout) -> future< T >
 Waits at most timeout, returning a future that retains any pending result. In cooperative threadless execution, ignores timeout and returns immediately without waiting. Repeated polling must yield to the host event loop to allow the result to become ready.
template<class T>
auto stlab::await_for (const future< T > &x, const std::chrono::nanoseconds &timeout) -> future< T >
 Equivalent to await_for(copy(x), timeout).

Function Documentation

◆ await()

template<class T>
auto stlab::await ( const future< T > & x) -> T

Equivalent to await(copy(x)).

◆ await_for()

template<class T>
auto stlab::await_for ( const future< T > & x,
const std::chrono::nanoseconds & timeout ) -> future< T >

Equivalent to await_for(copy(x), timeout).