|
MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
|
Owns a set of in-flight std::async futures on behalf of a subsystem. More...
#include <AsyncGroup.hpp>
Inheritance diagram for MayaFlux::Parallel::AsyncGroup< T >:
Collaboration diagram for MayaFlux::Parallel::AsyncGroup< T >:Public Types | |
| using | ExceptionHandler = std::function< void(std::exception_ptr)> |
| Exception policy invoked once per exception observed from a submitted future's get(). | |
Public Member Functions | |
| size_t | approx_pending () const noexcept |
| Approximate count of futures not yet reclaimed. | |
| AsyncGroup ()=default | |
| AsyncGroup (AsyncGroup &&)=delete | |
| AsyncGroup (const AsyncGroup &)=delete | |
| AsyncGroup (ExceptionHandler handler) | |
| Construct with an explicit exception policy. | |
| void | drain () |
| Blocks until every currently submitted future completes. | |
| AsyncGroup & | operator= (AsyncGroup &&)=delete |
| AsyncGroup & | operator= (const AsyncGroup &)=delete |
| void | submit (std::future< T > fut) |
Retains fut and opportunistically reclaims completed work. | |
| std::vector< std::exception_ptr > | take_errors () |
| Returns and clears exceptions accumulated with no handler set. | |
| ~AsyncGroup () | |
| Drains all in-flight work before destruction. | |
Private Member Functions | |
| void | finish (std::future< T > &f) |
| void | report (std::exception_ptr ep) |
Private Attributes | |
| Memory::SweepList< std::exception_ptr > | m_errors |
| ExceptionHandler | m_handler |
| Memory::SweepList< std::future< T > > | m_tasks |
Owns a set of in-flight std::async futures on behalf of a subsystem.
Centralizes the future-ownership mechanics that subsystems such as IOManager and Yantra::ComputeMatrix each implemented independently: submit work, retain the future past the initiating call, prune completed work opportunistically, and block on everything remaining at teardown.
AsyncGroup is not a thread pool or scheduler. It does not launch work itself; callers still call std::async (or any callable returning std::future<T>) and hand the future to submit(). It does not reuse threads, size a queue, or impose priorities or affinity. It only answers "who owns this future until it's done, and who notices if it failed."
Storage is MayaFlux::Memory::SweepList, so submission, opportunistic pruning, and drain are all lock-free and unbounded; see SweepList.hpp for the concurrency shape.
Exceptions from a submitted task are never silently discarded. Each one is reported to a policy: a caller-supplied handler if one was set at construction, or, absent a handler, retained internally and returned by take_errors() so a caller can inspect them explicitly.
| T | Result type of the tracked futures. Use AsyncGroup<void> for completion-only tracking, AsyncGroup<bool> for a group whose tasks report success/failure, and so on. |
Definition at line 51 of file AsyncGroup.hpp.