move Task to threadpool

master
Daniel Kolesa 2016-04-11 20:01:26 +01:00
parent 8f97190958
commit 99c1fd2707
1 changed files with 11 additions and 11 deletions

22
main.cc
View File

@ -35,17 +35,6 @@ using cscript::Bytecode;
/* 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 {
ThreadPool() {}
@ -112,6 +101,17 @@ struct ThreadPool {
}
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;
Mutex mtx;
Vector<Thread> thrs;