Create a RefCounted type and use it for Thread.

This should prevent me from actually creating 2 shared ptrs of
a single kernel object with their separate ref counts.
This commit is contained in:
Drew Galbraith 2023-06-06 19:05:03 -07:00
parent d9b17d96d7
commit 2e1357255c
8 changed files with 146 additions and 22 deletions

View file

@ -15,7 +15,7 @@ class Scheduler {
Process& CurrentProcess() { return current_thread_->process(); }
Thread& CurrentThread() { return *current_thread_; }
void Enqueue(const SharedPtr<Thread> thread) {
void Enqueue(const RefPtr<Thread>& thread) {
runnable_threads_.PushBack(thread);
}
@ -25,10 +25,10 @@ class Scheduler {
private:
bool enabled_ = false;
SharedPtr<Thread> current_thread_;
LinkedList<SharedPtr<Thread>> runnable_threads_;
RefPtr<Thread> current_thread_;
LinkedList<RefPtr<Thread>> runnable_threads_;
SharedPtr<Thread> sleep_thread_;
RefPtr<Thread> sleep_thread_;
Scheduler();
void SwapToCurrent(Thread& prev);