mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
Now that we have proper wait queues to drive waiter wakeup, we can use the wake actions to break out of the scheduler's idle loop when we've got a thread to run.
36 lines
669 B
C++
36 lines
669 B
C++
#include <Kernel/Thread.h>
|
|
#include <Kernel/WaitQueue.h>
|
|
|
|
WaitQueue::WaitQueue()
|
|
{
|
|
}
|
|
|
|
WaitQueue::~WaitQueue()
|
|
{
|
|
}
|
|
|
|
void WaitQueue::enqueue(Thread& thread)
|
|
{
|
|
InterruptDisabler disabler;
|
|
m_threads.append(&thread);
|
|
}
|
|
|
|
void WaitQueue::wake_one()
|
|
{
|
|
InterruptDisabler disabler;
|
|
if (m_threads.is_empty())
|
|
return;
|
|
if (auto* thread = m_threads.take_first())
|
|
thread->wake_from_queue();
|
|
Scheduler::stop_idling();
|
|
}
|
|
|
|
void WaitQueue::wake_all()
|
|
{
|
|
InterruptDisabler disabler;
|
|
if (m_threads.is_empty())
|
|
return;
|
|
while (!m_threads.is_empty())
|
|
m_threads.take_first()->wake_from_queue();
|
|
Scheduler::stop_idling();
|
|
}
|