Core: Let interrupted timing properly exit early

This commit is contained in:
Vicki Pfau
2025-12-30 21:34:38 -08:00
parent c7114d8fd3
commit fa4a97eb17
+17 -12
View File
@@ -39,12 +39,16 @@ void mTimingSchedule(struct mTiming* timing, struct mTimingEvent* event, int32_t
if (nextEvent < *timing->nextEvent) {
*timing->nextEvent = nextEvent;
}
struct mTimingEvent** previous;
struct mTimingEvent* next;
if (timing->reroot) {
timing->root = timing->reroot;
timing->reroot = NULL;
previous = &timing->reroot;
next = timing->reroot;
} else {
previous = &timing->root;
next = timing->root;
}
struct mTimingEvent** previous = &timing->root;
struct mTimingEvent* next = timing->root;
unsigned priority = event->priority;
while (next) {
int32_t nextWhen = next->when - timing->masterCycles;
@@ -63,12 +67,16 @@ void mTimingScheduleAbsolute(struct mTiming* timing, struct mTimingEvent* event,
}
void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent* event) {
struct mTimingEvent** previous;
struct mTimingEvent* next;
if (timing->reroot) {
timing->root = timing->reroot;
timing->reroot = NULL;
previous = &timing->reroot;
next = timing->reroot;
} else {
previous = &timing->root;
next = timing->root;
}
struct mTimingEvent** previous = &timing->root;
struct mTimingEvent* next = timing->root;
while (next) {
if (next == event) {
*previous = next->next;
@@ -105,13 +113,10 @@ int32_t mTimingTick(struct mTiming* timing, int32_t cycles) {
timing->root = next->next;
next->callback(timing, next->context, -nextWhen);
}
if (timing->reroot) {
if (UNLIKELY(timing->reroot)) {
timing->root = timing->reroot;
timing->reroot = NULL;
*timing->nextEvent = mTimingNextEvent(timing);
if (*timing->nextEvent <= 0) {
return mTimingTick(timing, 0);
}
}
return *timing->nextEvent;
}