#include <userver/engine/wait_any.hpp>
Stores a set of awaitables and allows waiting for completion of any of the stored awaitables.
Works with different types of awaitables:
No methods (except .dtor) should be called on a moved-out instance.
Definition at line 122 of file wait_any.hpp.
Public Member Functions | |
| WaitAnyContext (WaitAnyContext &&) noexcept | |
| WaitAnyContext & | operator= (WaitAnyContext &&other) noexcept |
| WaitAnyContext (const WaitAnyContext &)=delete | |
| WaitAnyContext & | operator= (const WaitAnyContext &)=delete |
| template<typename... Awaitables> | |
| void | Append (Awaitables &... awaitables) |
| Append the given awaitables and sequences of awaitables to the context. | |
| std::optional< std::uint64_t > | Wait () |
| Waits either for the completion of any of the awaitables stored in the context or for the cancellation of the caller. | |
| std::optional< std::uint64_t > | WaitUntil (Deadline deadline) |
| template<typename Rep, typename Period> | |
| std::optional< std::uint64_t > | WaitFor (const std::chrono::duration< Rep, Period > &duration) |
| template<typename Clock, typename Duration> | |
| std::optional< std::uint64_t > | WaitUntil (const std::chrono::time_point< Clock, Duration > &until) |
| std::size_t | GetSize () const noexcept |
| Returns the number of awaitables actually stored in the context. | |
| std::uint64_t | GetNextIndex () const noexcept |
| Returns the next awaitable index. | |
| void engine::WaitAnyContext::Append | ( | Awaitables &... | awaitables | ) |
Append the given awaitables and sequences of awaitables to the context.
Each passed awaitable could be either a single awaitable or a container of awaitables. In the latter case all awaitables from the container are appended to the context. The appended awaitables will have indexes [GetNextIndex() before the call, GetNextIndex() after the call - 1].
Definition at line 203 of file wait_any.hpp.
|
noexcept |
Returns the next awaitable index.
It could be used to calculate indexes of awaitables appended via Append call.
|
noexcept |
Returns the number of awaitables actually stored in the context.
It consists of actively awaited and pending subscription awaitables. Already notified awaitables are dropped out.
| std::optional< std::uint64_t > engine::WaitAnyContext::Wait | ( | ) |
Waits either for the completion of any of the awaitables stored in the context or for the cancellation of the caller.
std::nullopt if there are no completed awaitables (possible if current task was cancelled).This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Definition at line 151 of file wait_any.hpp.
|
inline |
Definition at line 157 of file wait_any.hpp.