mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
5859e16e53
Instead of using the generic block mechanism, wait-queued threads now go into the special Queued state. This fixes an issue where signal dispatch would unblock a wait-queued thread (because signal dispatch unblocks blocked threads) and cause confusion since the thread only expected to be awoken by the queue.
34 lines
609 B
C++
34 lines
609 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();
|
|
}
|
|
|
|
void WaitQueue::wake_all()
|
|
{
|
|
InterruptDisabler disabler;
|
|
if (m_threads.is_empty())
|
|
return;
|
|
while (!m_threads.is_empty())
|
|
m_threads.take_first()->wake_from_queue();
|
|
}
|