Added getActiveTasks() function to count how many tasks are running or suspended.
This commit is contained in:
@@ -174,6 +174,20 @@ void SimpleTaskLoop::addStoredTask(StoredTask&& storedTask) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t SimpleTaskLoop::getActiveTasks() const noexcept
|
||||
{
|
||||
std::size_t sum = 0;
|
||||
for (const StoredTask& task : mijin::chain(tasks_, newTasks_))
|
||||
{
|
||||
const TaskStatus status = task.task ? task.task->status() : TaskStatus::FINISHED;
|
||||
if (status == TaskStatus::SUSPENDED || status == TaskStatus::RUNNING)
|
||||
{
|
||||
++sum;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void MultiThreadedTaskLoop::transferCurrentTask(TaskLoop& otherLoop) noexcept
|
||||
{
|
||||
if (&otherLoop == this) {
|
||||
|
||||
Reference in New Issue
Block a user