50template <
typename T =
void>
106 [](std::future<T>& f) {
107 return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
109 [
this](std::future<T>& f) {
finish(f); });
134 std::vector<std::exception_ptr> errors;
136 errors.push_back(std::move(ep));
154 if constexpr (std::is_void_v<T>) {
160 report(std::current_exception());
void push(T value) noexcept
Publishes value for later sweep() or drain().
void drain(Finish finish)
Blocking pass that finalizes every item currently held.
Lock-free, unbounded, multi-producer collection of in-flight items.
size_t approx_pending() const noexcept
Approximate count of futures not yet reclaimed.
~AsyncGroup()
Drains all in-flight work before destruction.
AsyncGroup(ExceptionHandler handler)
Construct with an explicit exception policy.
std::vector< std::exception_ptr > take_errors()
Returns and clears exceptions accumulated with no handler set.
AsyncGroup & operator=(const AsyncGroup &)=delete
void report(std::exception_ptr ep)
AsyncGroup(AsyncGroup &&)=delete
AsyncGroup & operator=(AsyncGroup &&)=delete
Memory::SweepList< std::exception_ptr > m_errors
AsyncGroup(const AsyncGroup &)=delete
ExceptionHandler m_handler
void finish(std::future< T > &f)
void drain()
Blocks until every currently submitted future completes.
void submit(std::future< T > fut)
Retains fut and opportunistically reclaims completed work.
Memory::SweepList< std::future< T > > m_tasks
std::function< void(std::exception_ptr)> ExceptionHandler
Exception policy invoked once per exception observed from a submitted future's get().
Owns a set of in-flight std::async futures on behalf of a subsystem.