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();
|
semaphore_.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThreadPool::CancelTasks() {
|
||||||
|
task_runner_.CancelTasks();
|
||||||
|
}
|
||||||
|
|
||||||
void ThreadPool::WorkerMain() {
|
void ThreadPool::WorkerMain() {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
semaphore_.acquire();
|
semaphore_.acquire();
|
||||||
|
|
|
@ -39,6 +39,8 @@ class ThreadPool {
|
||||||
semaphore_.release();
|
semaphore_.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CancelTasks();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::thread> threads_;
|
std::vector<std::thread> threads_;
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,9 @@ Engine::Engine(Platform* platform)
|
||||||
Engine::~Engine() {
|
Engine::~Engine() {
|
||||||
LOG << "Shutting down engine.";
|
LOG << "Shutting down engine.";
|
||||||
|
|
||||||
|
thread_pool_.CancelTasks();
|
||||||
|
thread_pool_.Shutdown();
|
||||||
|
|
||||||
game_.reset();
|
game_.reset();
|
||||||
stats_.reset();
|
stats_.reset();
|
||||||
textures_.clear();
|
textures_.clear();
|
||||||
|
|
|
@ -987,6 +987,7 @@ void RendererVulkan::Shutdown() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LOG << "Shutting down renderer.";
|
LOG << "Shutting down renderer.";
|
||||||
|
task_runner_.CancelTasks();
|
||||||
quit_.store(true, std::memory_order_relaxed);
|
quit_.store(true, std::memory_order_relaxed);
|
||||||
semaphore_.release();
|
semaphore_.release();
|
||||||
setup_thread_.join();
|
setup_thread_.join();
|
||||||
|
|
Loading…
Reference in New Issue