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:
parent
e7940e55e0
commit
82ca373e81
1 changed files with 6 additions and 1 deletions
7
main.cpp
7
main.cpp
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue