blob: 96fc13bda5fd934239c16a28f4fd1325ce399d67 (
plain)
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
|
#pragma once
#include <mbgl/actor/mailbox.hpp>
#include <mbgl/actor/scheduler.hpp>
#include <condition_variable>
#include <mutex>
#include <queue>
#include <thread>
namespace mbgl {
class ThreadPool final : public Scheduler {
public:
explicit ThreadPool(std::size_t count);
~ThreadPool() override;
void schedule(std::function<void()>) override;
private:
std::vector<std::thread> threads;
std::queue<std::function<void()>> queue;
std::mutex mutex;
std::condition_variable cv;
bool terminate{ false };
};
} // namespace mbgl
|