vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
thread_pool_executor.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/concurrency/completion_notifier.hpp>
6#include <vitrio/concurrency/executor.hpp>
7#include <vitrio/concurrency/task.hpp>
8#include <vitrio/export.hpp>
9#include <vitrio/platform.hpp>
10
11#include <cstddef>
12#include <memory>
13
14namespace vitrio
15{
16
36class VITRIO_API thread_pool_executor final
37 : public executor
38{
39public:
46 explicit thread_pool_executor(std::size_t worker_count);
47
48 thread_pool_executor(const thread_pool_executor &other) = delete;
50
51 ~thread_pool_executor() override;
52
54 operator=(const thread_pool_executor &other) = delete;
56 operator=(thread_pool_executor &&other) = delete;
57
63 std::size_t get_worker_count() const noexcept;
64
72 void submit(
73 std::unique_ptr<task> t,
74 std::shared_ptr<completion_notifier> notifier
75 ) override;
76
77private:
78 class implementation;
79 VITRIO_STD_MEMBER_INTERFACE
80 std::unique_ptr<implementation> m_implementation;
81};
82
83} // namespace vitrio
Where a finished unit of work is reported.
Definition completion_notifier.hpp:20
Where a task is handed off to run, now or later.
Definition executor.hpp:26
One unit of work an executor can run.
Definition task.hpp:18
An executor backed by a fixed pool of worker threads.
Definition thread_pool_executor.hpp:38
std::size_t get_worker_count() const noexcept
Get the number of worker threads.
thread_pool_executor(std::size_t worker_count)
Construct a pool with a given number of worker threads.