mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-02 01:08:27 +00:00
I hate timers
This commit is contained in:
parent
1354b0f7fa
commit
8881467505
4 changed files with 69 additions and 12 deletions
|
@ -35,6 +35,7 @@ class Kernel {
|
|||
std::vector<KernelObject> objects;
|
||||
std::vector<Handle> portHandles;
|
||||
std::vector<Handle> mutexHandles;
|
||||
std::vector<Handle> timerHandles;
|
||||
|
||||
// Thread indices, sorted by priority
|
||||
std::vector<int> threadIndices;
|
||||
|
@ -84,6 +85,7 @@ private:
|
|||
void releaseMutex(Mutex* moo);
|
||||
void cancelTimer(Timer* timer);
|
||||
void signalTimer(Handle timerHandle, Timer* timer);
|
||||
void updateTimer(Handle timerHandle, Timer* timer);
|
||||
|
||||
// Wake up the thread with the highest priority out of all threads in the waitlist
|
||||
// Returns the index of the woken up thread
|
||||
|
@ -182,6 +184,14 @@ public:
|
|||
void requireReschedule() { needReschedule = true; }
|
||||
|
||||
void evalReschedule() {
|
||||
for (auto handle : timerHandles) {
|
||||
const auto object = getObject(handle, KernelObjectType::Timer);
|
||||
if (object != nullptr) {
|
||||
Timer* timer = object->getData<Timer>();
|
||||
updateTimer(handle, timer);
|
||||
}
|
||||
}
|
||||
|
||||
if (needReschedule) {
|
||||
needReschedule = false;
|
||||
rescheduleThreads();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue