mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
41376d4662
There was a time window between releasing Lock::m_lock and calling into the lock's WaitQueue where someone else could take m_lock and bring two threads into a deadlock situation. Fix this issue by holding Lock::m_lock until interrupts are disabled by either Thread::wait_on() or WaitQueue::wake_one().
19 lines
370 B
C++
19 lines
370 B
C++
#pragma once
|
|
|
|
#include <AK/Atomic.h>
|
|
#include <AK/SinglyLinkedList.h>
|
|
#include <Kernel/Thread.h>
|
|
|
|
class WaitQueue {
|
|
public:
|
|
WaitQueue();
|
|
~WaitQueue();
|
|
|
|
void enqueue(Thread&);
|
|
void wake_one(Atomic<bool>* lock = nullptr);
|
|
void wake_all();
|
|
|
|
private:
|
|
typedef IntrusiveList<Thread, &Thread::m_wait_queue_node> ThreadList;
|
|
ThreadList m_threads;
|
|
};
|