forked from OctaForge/OctaBuild
move Task to threadpool
parent
8f97190958
commit
99c1fd2707
22
main.cc
22
main.cc
|
@ -35,17 +35,6 @@ using cscript::Bytecode;
|
||||||
|
|
||||||
/* thread pool */
|
/* thread pool */
|
||||||
|
|
||||||
struct Task {
|
|
||||||
ostd::Function<void()> cb;
|
|
||||||
Task *next = nullptr;
|
|
||||||
Task() = delete;
|
|
||||||
Task(const Task &) = delete;
|
|
||||||
Task(Task &&) = delete;
|
|
||||||
Task(ostd::Function<void()> &&cbf): cb(ostd::move(cbf)) {}
|
|
||||||
Task &operator=(const Task &) = delete;
|
|
||||||
Task &operator=(Task &&) = delete;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ThreadPool {
|
struct ThreadPool {
|
||||||
ThreadPool() {}
|
ThreadPool() {}
|
||||||
|
|
||||||
|
@ -112,6 +101,17 @@ struct ThreadPool {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct Task {
|
||||||
|
ostd::Function<void()> cb;
|
||||||
|
Task *next = nullptr;
|
||||||
|
Task() = delete;
|
||||||
|
Task(const Task &) = delete;
|
||||||
|
Task(Task &&) = delete;
|
||||||
|
Task(ostd::Function<void()> &&cbf): cb(ostd::move(cbf)) {}
|
||||||
|
Task &operator=(const Task &) = delete;
|
||||||
|
Task &operator=(Task &&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
Condition cond;
|
Condition cond;
|
||||||
Mutex mtx;
|
Mutex mtx;
|
||||||
Vector<Thread> thrs;
|
Vector<Thread> thrs;
|
||||||
|
|
Loading…
Reference in New Issue