Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::async::ThreadPoolExecutor Class Reference

Thread pool executor. More...

#include <executor.hpp>

Inheritance diagram for aria::async::ThreadPoolExecutor:
[legend]

Public Member Functions

 ThreadPoolExecutor (std::size_t threads=std::thread::hardware_concurrency())
 ~ThreadPoolExecutor () override
void post (std::function< void()> fn) override
 Legacy / canonical executor entry point.
aria::SchedulerCaps caps () const noexcept override
 Worker pool: NOT safe as the graph executor.
std::size_t worker_count () const noexcept
void wait_idle ()
 Block until queue is drained AND no worker is currently running a task.
Public Member Functions inherited from aria::async::IExecutor
 ~IExecutor () override=default
void schedule (std::function< void()> fn) override
 Submit fn for execution "soon". Defines Caps::Post.
virtual bool is_safe_graph_executor () const noexcept
 True iff this executor is safe to use as the graph-thread (UI) executor.
virtual bool is_safe_worker_executor () const noexcept
 True iff this executor can host worker tasks.
Public Member Functions inherited from aria::IScheduler
virtual ~IScheduler ()=default
virtual void schedule_after (std::chrono::milliseconds delay, std::function< void()> fn)
 Submit fn for execution after delay.
virtual bool is_main_thread () const noexcept
 True iff the calling thread is the scheduler's "main" thread.

Detailed Description

Thread pool executor.

Constructor & Destructor Documentation

◆ ThreadPoolExecutor()

aria::async::ThreadPoolExecutor::ThreadPoolExecutor ( std::size_t threads = std::thread::hardware_concurrency())
inlineexplicit

◆ ~ThreadPoolExecutor()

aria::async::ThreadPoolExecutor::~ThreadPoolExecutor ( )
inlineoverride

Member Function Documentation

◆ post()

void aria::async::ThreadPoolExecutor::post ( std::function< void()> fn)
inlineoverridevirtual

Legacy / canonical executor entry point.

Implementations override this; the unified IScheduler::schedule(fn) is wired to it.

Implements aria::async::IExecutor.

◆ caps()

aria::SchedulerCaps aria::async::ThreadPoolExecutor::caps ( ) const
inlinenodiscardoverridevirtualnoexcept

Worker pool: NOT safe as the graph executor.

Property writes from a pool thread would race the reactive graph's owner-thread invariant. Caps advertise Post + WorkerSafe + Autonomous (no pump required); GraphSafe is explicitly absent.

Reimplemented from aria::async::IExecutor.

◆ worker_count()

std::size_t aria::async::ThreadPoolExecutor::worker_count ( ) const
inlinenodiscardnoexcept

◆ wait_idle()

void aria::async::ThreadPoolExecutor::wait_idle ( )
inline

Block until queue is drained AND no worker is currently running a task.

Uses a condition variable rather than a bounded spin-sleep so long tasks don't race the destructor.


The documentation for this class was generated from the following file: