Check for runnable threads
This commit is contained in:
parent
57517252d8
commit
70497c37fb
@ -88,22 +88,29 @@ namespace Scheduler
|
||||
Thread* old = g_current;
|
||||
if (old->is_idle())
|
||||
{
|
||||
auto maybe_first = g_threads.last();
|
||||
if (maybe_first.has_error()) // No threads!!
|
||||
auto maybe_last = g_threads.last();
|
||||
if (maybe_last.has_error()) // No threads!!
|
||||
return &g_idle;
|
||||
g_current = old = maybe_first.value();
|
||||
g_current = old = maybe_last.value();
|
||||
}
|
||||
|
||||
bool has_found_thread = false;
|
||||
|
||||
do {
|
||||
auto maybe_next = g_threads.next(g_current);
|
||||
if (maybe_next.has_error()) g_current = g_threads.first().value();
|
||||
else
|
||||
g_current = maybe_next.value();
|
||||
|
||||
if (true) // FIXME: Check if the current task is runnable.
|
||||
if (g_current->state == ThreadState::Runnable)
|
||||
{
|
||||
has_found_thread = true;
|
||||
break;
|
||||
}
|
||||
} while (g_current != old);
|
||||
|
||||
if (!has_found_thread) g_current = &g_idle;
|
||||
|
||||
return g_current;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user