-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIMetaThreadPool.hpp
More file actions
43 lines (38 loc) · 1.52 KB
/
Copy pathIMetaThreadPool.hpp
File metadata and controls
43 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#include <cstddef>
#include <functional>
namespace Meta
{
/**
* \brief Minimal abstract pool interface the scheduler uses to dispatch tasks.
* Implementations decide how work is queued and which OS thread runs it;
* the scheduler only needs a way to submit a callable and a worker-count probe.
*
* Completion tracking is intentionally the CALLER's responsibility:
* a per-task std::future<void> would force a heap allocation per submission
* and box the wake-up into a std::future primitive that the scheduler does not need.
* The scheduler's Execute() instead uses a single atomic<bool> per scheduled task,
* which it owns for the duration of the tick.
*/
class IMetaThreadPool
{
public:
virtual ~IMetaThreadPool() = default;
IMetaThreadPool(const IMetaThreadPool&) = delete;
IMetaThreadPool& operator=(const IMetaThreadPool&) = delete;
/**
* \brief Submit a unit of work to the pool.
* The task runs on whichever worker picks it up next; ordering between submissions
* is the pool's internal concern and not exposed to the caller.
* The caller is responsible for any cross-task synchronisation (parents, barriers).
*/
virtual void RunTask(std::function<void()> task) = 0;
/**
* \brief Number of OS threads the pool keeps alive.
* Useful for sanity checks and for sizing decisions in callers.
*/
[[nodiscard]] virtual size_t GetWorkerCount() const = 0;
protected:
IMetaThreadPool() = default;
};
}