Skip to content

Commit

Permalink
Acquire mutex during thread termination
Browse files Browse the repository at this point in the history
  • Loading branch information
mwilsnd committed May 20, 2024
1 parent 94cf43c commit ce46972
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/mbgl/util/thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ void ThreadedSchedulerBase::terminate() {
// Run any leftover render jobs
runRenderJobs();

terminated = true;
{
std::unique_lock<std::mutex> lock(workerMutex);
terminated = true;
}

// Wake up all threads so that they shut down
cvAvailable.notify_all();
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/util/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ThreadedSchedulerBase : public Scheduler {
std::mutex workerMutex;
std::shared_mutex taggedQueueLock;
util::ThreadLocal<ThreadedSchedulerBase> owningThreadPool;
std::atomic_bool terminated{false};
bool terminated{false};

// Task queues bucketed by tag address
struct Queue {
Expand Down

0 comments on commit ce46972

Please sign in to comment.