Skip to content

Commit

Permalink
Stop periodic task thread when all jobs have been removed
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Jan 15, 2025
1 parent dcfe45b commit 7972fdd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/cpp/threadutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ void ThreadUtility::priv_data::doPeriodicTasks()
TimePoint nextOperationTime = currentTime + this->maxDelay;
{
std::lock_guard<std::recursive_mutex> lock(this->job_mutex);
if (this->jobs.empty())
break;
for (auto& item : this->jobs)
{
if (this->terminated)
Expand Down Expand Up @@ -395,6 +393,8 @@ void ThreadUtility::priv_data::doPeriodicTasks()
break;
this->jobs.erase(pItem);
}
if (this->jobs.empty())
break;

std::unique_lock<std::mutex> lock(this->interrupt_mutex);
this->interrupt.wait_until(lock, nextOperationTime);
Expand Down

0 comments on commit 7972fdd

Please sign in to comment.