diff options
author | Robin Burchell <robin+git@viroteck.net> | 2019-07-19 17:21:13 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-22 09:42:39 +0200 |
commit | 342f7a6b0fe625d9d9920bd80659dd8f3e693578 (patch) | |
tree | ec0f185eae2f059b615e3e111521e106c20d50f2 /Kernel/Scheduler.h | |
parent | c1ed16c8e80ae4365afc6023d919751d83acb74c (diff) | |
download | serenity-342f7a6b0fe625d9d9920bd80659dd8f3e693578.zip |
Move runnable/non-runnable list control entirely over to Scheduler
This way, we can change how the scheduler works without having to change Thread too.
Diffstat (limited to 'Kernel/Scheduler.h')
-rw-r--r-- | Kernel/Scheduler.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index 5cdb2c3b64..5363e00d9f 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -2,6 +2,8 @@ #include <AK/Assertions.h> #include <AK/Types.h> +#include <AK/Function.h> +#include <AK/IntrusiveList.h> class Process; class Thread; @@ -27,6 +29,29 @@ public: static bool is_active(); static void beep(); + template<typename Callback> + static inline IterationDecision for_each_runnable(Callback callback) + { + return for_each_runnable_func([callback](Thread& thread) { + return callback(thread); + }); + } + + template<typename Callback> + static inline IterationDecision for_each_nonrunnable(Callback callback) + { + return for_each_nonrunnable_func([callback](Thread& thread) { + return callback(thread); + }); + } + + static void init_thread(Thread& thread); + static void update_state_for_thread(Thread& thread); + private: static void prepare_for_iret_to_new_process(); + static IterationDecision for_each_runnable_func(Function<IterationDecision(Thread&)>&& callback); + static IterationDecision for_each_nonrunnable_func(Function<IterationDecision(Thread&)>&& callback); + }; + |