Skip to content

Commit

Permalink
#5345: Allow clearance of pending tasks only
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 4, 2020
1 parent 8f82d54 commit a7b710e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions libs/TaskQueue.h
Expand Up @@ -39,15 +39,20 @@ class TaskQueue
}
}

// Removes all tasks that have not been processed yet
// Doesn't affect the currently running one
void clearPendingTasks()
{
// Lock the queue and remove any tasks such that no new ones are added
std::lock_guard<std::mutex> lock(_queueLock);
_queue.clear();
}

// Clears the queue. This might block waiting for any currently
// active taks to finish
// active task to finish
void clear()
{
{
// Lock the queue and remove any tasks such that no new ones are added
std::lock_guard<std::mutex> lock(_queueLock);
_queue.clear();
}
clearPendingTasks();

_current = std::future<void>();
_finished = std::future<void>();
Expand Down

0 comments on commit a7b710e

Please sign in to comment.