mirror of https://github.com/auygun/kaliber.git
Cancel tasks on shutdown
This commit is contained in:
parent
f54835e5f3
commit
0876203d82
|
@ -56,6 +56,10 @@ void ThreadPool::PostTaskAndReply(const Location& from,
|
|||
semaphore_.release();
|
||||
}
|
||||
|
||||
void ThreadPool::CancelTasks() {
|
||||
task_runner_.CancelTasks();
|
||||
}
|
||||
|
||||
void ThreadPool::WorkerMain() {
|
||||
for (;;) {
|
||||
semaphore_.acquire();
|
||||
|
|
|
@ -39,6 +39,8 @@ class ThreadPool {
|
|||
semaphore_.release();
|
||||
}
|
||||
|
||||
void CancelTasks();
|
||||
|
||||
private:
|
||||
std::vector<std::thread> threads_;
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ Engine::Engine(Platform* platform)
|
|||
Engine::~Engine() {
|
||||
LOG << "Shutting down engine.";
|
||||
|
||||
thread_pool_.CancelTasks();
|
||||
thread_pool_.Shutdown();
|
||||
|
||||
game_.reset();
|
||||
stats_.reset();
|
||||
textures_.clear();
|
||||
|
|
|
@ -987,6 +987,7 @@ void RendererVulkan::Shutdown() {
|
|||
return;
|
||||
|
||||
LOG << "Shutting down renderer.";
|
||||
task_runner_.CancelTasks();
|
||||
quit_.store(true, std::memory_order_relaxed);
|
||||
semaphore_.release();
|
||||
setup_thread_.join();
|
||||
|
|
Loading…
Reference in New Issue