1
0
Fork 0
mirror of https://gitlab.com/niansa/discord_llama.git synced 2025-03-06 20:48:25 +01:00

Fixed threads getting stuck

This commit is contained in:
niansa 2023-05-21 21:54:09 +02:00
parent e7940e55e0
commit 82ca373e81

View file

@ -796,13 +796,18 @@ public:
while (true) {
// Check that there are no other tasks with the same name
bool is_unique = true;
bool any_non_suspended = false;
for (const auto& other_task : task.get_scheduler().get_tasks()) {
if (&task == other_task.get()) continue;
if (task.get_name() == other_task->get_name()) {
is_unique = false;
break;
}
if (!other_task->is_suspended()) {
any_non_suspended = true;
}
}
// Stop looking if there is no task that isn't suspended
if (!any_non_suspended) break;
// Stop looking if task is unique
if (is_unique) break;
// Suspend, we'll be woken up by that other task