mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
f067730f6b
The kernel's Lock class now uses a proper wait queue internally instead of just having everyone wake up regularly to try to acquire the lock. We also keep the donation mechanism, so that whenever someone tries to take the lock and fails, that thread donates the remainder of its timeslice to the current lock holder. After unlocking a Lock, the unlocking thread calls WaitQueue::wake_one, which unblocks the next thread in queue.
18 lines
248 B
C++
18 lines
248 B
C++
#pragma once
|
|
|
|
#include <AK/SinglyLinkedList.h>
|
|
|
|
class Thread;
|
|
|
|
class WaitQueue {
|
|
public:
|
|
WaitQueue();
|
|
~WaitQueue();
|
|
|
|
void enqueue(Thread&);
|
|
void wake_one();
|
|
void wake_all();
|
|
|
|
private:
|
|
SinglyLinkedList<Thread*> m_threads;
|
|
};
|