|
vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
|
An executor backed by a fixed pool of worker threads. More...
#include <vitrio/concurrency/thread_pool_executor.hpp>


Public Member Functions | |
| thread_pool_executor (std::size_t worker_count) | |
| Construct a pool with a given number of worker threads. | |
| thread_pool_executor (const thread_pool_executor &other)=delete | |
| thread_pool_executor (thread_pool_executor &&other)=delete | |
| thread_pool_executor & | operator= (const thread_pool_executor &other)=delete |
| thread_pool_executor & | operator= (thread_pool_executor &&other)=delete |
| std::size_t | get_worker_count () const noexcept |
| Get the number of worker threads. | |
| void | submit (std::unique_ptr< task > t, std::shared_ptr< completion_notifier > notifier) override |
| Queue a unit of work for a worker to run. | |
Public Member Functions inherited from vitrio::executor | |
| executor (const executor &other)=default | |
| executor (executor &&other)=default | |
| executor & | operator= (const executor &other)=default |
| executor & | operator= (executor &&other)=default |
An executor backed by a fixed pool of worker threads.
Every worker pulls the next submitted task from one shared queue, runs it, and reports its outcome to the notifier it was submitted with, catching whatever the task threw. Submitting never blocks the caller and never runs the task itself; a task queued while every worker is busy simply waits its turn. The queue is unbounded.
The worker count should track the concurrency the destination the tasks read from or write to actually supports, not the number of CPU cores: a worker mostly blocks in I/O rather than computing.
The destructor waits for every already-queued task to run before returning, submitted or not yet started.
|
explicit |
Construct a pool with a given number of worker threads.
| worker_count | Threads to spawn. Must be greater than zero. |
| std::invalid_argument | If worker_count is zero. |
|
noexcept |
Get the number of worker threads.
|
overridevirtual |
Queue a unit of work for a worker to run.
| t | The work to run. Must not be null. |
| notifier | Where the outcome is reported. Must not be null. |
| std::invalid_argument | If t or notifier is null. |
Implements vitrio::executor.