Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
pangea_detail::DesktopPool Class Reference

Public Member Functions

 DesktopPool (size_t count)
 Start the desktop worker pool.
 ~DesktopPool ()
 Wake and join the workers before destroying shared batch state.
size_t size () const
 Report the fixed worker capacity.
size_t peak_workers ()
 Read the lifetime concurrency high-water mark.
bool cancelled () const
 Check whether the current batch has failed or been interrupted.
void run (size_t count, std::function< void(size_t)> operation, const std::function< void()> &checkpoint)
 Run indexed work and wait for every active callback to finish.

Private Member Functions

void work ()
 Claim and execute jobs until the coordinator shuts down the pool.

Private Attributes

std::vector< std::thread > workers
std::mutex mutex
std::condition_variable ready
std::condition_variable completed
std::function< void(size_t)> task
size_t next_job = 0
size_t job_count = 0
size_t active = 0
size_t peak_active = 0
bool shutdown = false
std::exception_ptr failure
std::atomic< bool > cancel {false}

Detailed Description

Definition at line 150 of file pangea.cpp.

Constructor & Destructor Documentation

◆ DesktopPool()

pangea_detail::DesktopPool::DesktopPool ( size_t count)
inlineexplicit

Start the desktop worker pool.

Parameters
countNumber of worker threads.

Block termination signals while spawning so workers inherit the mask and shutdown remains the coordinator's responsibility.

Definition at line 193 of file pangea.cpp.

◆ ~DesktopPool()

pangea_detail::DesktopPool::~DesktopPool ( )
inline

Wake and join the workers before destroying shared batch state.

Precondition
No coordinator call to run is in progress.

Definition at line 218 of file pangea.cpp.

Member Function Documentation

◆ cancelled()

bool pangea_detail::DesktopPool::cancelled ( ) const
inline

Check whether the current batch has failed or been interrupted.

Returns
True when workers should stop at their next checkpoint.

Definition at line 237 of file pangea.cpp.

◆ peak_workers()

size_t pangea_detail::DesktopPool::peak_workers ( )
inline

Read the lifetime concurrency high-water mark.

Returns
Greatest number of simultaneously active jobs.

Definition at line 231 of file pangea.cpp.

◆ run()

void pangea_detail::DesktopPool::run ( size_t count,
std::function< void(size_t)> operation,
const std::function< void()> & checkpoint )
inline

Run indexed work and wait for every active callback to finish.

Parameters
countNumber of jobs.
operationWorker callback; invocations may overlap.
checkpointCoordinator callback for resource and stop checks.

Poll the checkpoint while waiting. Preserve the first failure and rethrow it only after callbacks no longer borrow batch state.

Precondition
One coordinator calls this method; it is not reentrant.

Definition at line 246 of file pangea.cpp.

◆ size()

size_t pangea_detail::DesktopPool::size ( ) const
inline

Report the fixed worker capacity.

Returns
Number of threads, whether idle or active.

Definition at line 228 of file pangea.cpp.

◆ work()

void pangea_detail::DesktopPool::work ( )
inlineprivate

Claim and execute jobs until the coordinator shuts down the pool.

Execute callbacks outside the mutex. On failure, stop assigning jobs but let in-flight callbacks drain before the batch returns.

Definition at line 164 of file pangea.cpp.

Field Documentation

◆ active

size_t pangea_detail::DesktopPool::active = 0
private

Definition at line 155 of file pangea.cpp.

◆ cancel

std::atomic<bool> pangea_detail::DesktopPool::cancel {false}
private

Definition at line 159 of file pangea.cpp.

◆ completed

std::condition_variable pangea_detail::DesktopPool::completed
private

Definition at line 153 of file pangea.cpp.

◆ failure

std::exception_ptr pangea_detail::DesktopPool::failure
private

Definition at line 158 of file pangea.cpp.

◆ job_count

size_t pangea_detail::DesktopPool::job_count = 0
private

Definition at line 155 of file pangea.cpp.

◆ mutex

std::mutex pangea_detail::DesktopPool::mutex
private

Definition at line 152 of file pangea.cpp.

◆ next_job

size_t pangea_detail::DesktopPool::next_job = 0
private

Definition at line 155 of file pangea.cpp.

◆ peak_active

size_t pangea_detail::DesktopPool::peak_active = 0
private

Definition at line 156 of file pangea.cpp.

◆ ready

std::condition_variable pangea_detail::DesktopPool::ready
private

Definition at line 153 of file pangea.cpp.

◆ shutdown

bool pangea_detail::DesktopPool::shutdown = false
private

Definition at line 157 of file pangea.cpp.

◆ task

std::function<void(size_t)> pangea_detail::DesktopPool::task
private

Definition at line 154 of file pangea.cpp.

◆ workers

std::vector<std::thread> pangea_detail::DesktopPool::workers
private

Definition at line 151 of file pangea.cpp.


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