mirror of
https://github.com/ProgramSnail/build_system_2022.git
synced 2025-12-06 00:48:42 +00:00
init
This commit is contained in:
parent
4d899f64a7
commit
b4a7121411
23 changed files with 681 additions and 11 deletions
30
thread_pool.hpp
Normal file
30
thread_pool.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "dependency_manager.hpp"
|
||||
#include "task_queue.hpp"
|
||||
|
||||
namespace build_system {
|
||||
|
||||
class ThreadPool {
|
||||
public:
|
||||
explicit ThreadPool(size_t num_threads) : num_threads_(num_threads) {}
|
||||
|
||||
void addTarget(Task&& task, size_t id, const std::vector<size_t>& dependences);
|
||||
|
||||
void start();
|
||||
|
||||
void wait();
|
||||
|
||||
private:
|
||||
size_t num_threads_;
|
||||
std::vector<std::thread> threads_;
|
||||
TaskQueue task_queue_;
|
||||
DependencyManager dependency_manager_;
|
||||
};
|
||||
|
||||
}; // namespace build_system
|
||||
Loading…
Add table
Add a link
Reference in a new issue