-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJobEngine.h
More file actions
29 lines (26 loc) · 768 Bytes
/
Copy pathJobEngine.h
File metadata and controls
29 lines (26 loc) · 768 Bytes
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
#pragma once
#include <cstdint>
#include <random>
#include <vector>
#include "JobExecutor.h"
namespace tooibox
{
class JobEngine
{
public:
UTILITY_API static JobEngine& GetInstance();
UTILITY_API JobEngine();
UTILITY_API ~JobEngine();
UTILITY_API JobExecutor* GetRandomWorker();
UTILITY_API JobExecutor* GetForegroundExecutor();
UTILITY_API JobExecutor* GetThreadWorker();
UTILITY_API size_t GetNumberOfBackgroundWorkers() const noexcept;
private:
// TODOJM: Fetch number of cores avaliable on CPU
constexpr static std::size_t NR_OF_EXECUTORS = 8;
std::vector<std::unique_ptr<JobExecutor>> m_jobExecutors;
std::random_device m_randomDevice;
std::mt19937 m_randomGenerator;
std::uniform_int_distribution<unsigned int> m_randomExecutorDistribution;
};
}