refactor
This commit is contained in:
@ -100,15 +100,16 @@ void tasks::stop() {
|
|||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
unique_mutex_lock lock(mutex_);
|
unique_mutex_lock lock(mutex_);
|
||||||
|
std::vector<std::unique_ptr<std::jthread>> threads;
|
||||||
|
std::swap(threads, task_threads_);
|
||||||
|
|
||||||
|
std::deque<scheduled_task> tasks;
|
||||||
|
std::swap(tasks, tasks_);
|
||||||
notify_.notify_all();
|
notify_.notify_all();
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
task_threads_.clear();
|
threads.clear();
|
||||||
|
tasks.clear();
|
||||||
lock.lock();
|
|
||||||
tasks_.clear();
|
|
||||||
notify_.notify_all();
|
|
||||||
lock.unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tasks::task_thread() {
|
void tasks::task_thread() {
|
||||||
|
Reference in New Issue
Block a user