blob: e3541e93f3d8cb38984939fa443f3186bb250c2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#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();
}
|