Skip to content

Commit 9c2e847

Browse files
Unified Timing Primitives & Same-Tick Repeat
- `vTaskYieldNextTick()` now forwards to `vTaskDelayUntil(0)` — removing redundant logic and ensuring unified behavior. - `vTaskRepeatThisTick()` now builds on the same delay primitive for consistency and clarity. - Support for *same-tick task repeats* (via `vTaskRepeatThisTick()`), enabling staged cooperative operations.
1 parent 9873a08 commit 9c2e847

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

src/TaskScheduler.h

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,6 @@ class TaskScheduler : public IScheduler {
194194
overrideNext = tickNow + ms;
195195
}
196196

197-
/**
198-
* @brief Yield current task until next tick (cheap throttle).
199-
*/
200-
inline void vTaskYieldNextTick() {
201-
if (!hasCurrentTask()) return;
202-
overrideSet = true;
203-
overrideNext = tickNow; // same-tick re-run prevented by ranMask
204-
}
205-
206197
/**
207198
* @brief Period-locked delay: schedule next wake at the first
208199
* future multiple of @p period from this run's release time.
@@ -233,6 +224,22 @@ class TaskScheduler : public IScheduler {
233224
overrideNext = anchor + k * period;
234225
}
235226

227+
/**
228+
* @brief Yield current task until next tick (cheap throttle).
229+
*/
230+
inline void vTaskYieldNextTick() {
231+
vTaskDelayUntil(0);
232+
}
233+
234+
/**
235+
* @brief Request to run the current task again within this same scheduler tick.
236+
*/
237+
inline void vTaskRepeatThisTick() {
238+
vTaskDelayUntil(0);
239+
cascadePending = true; // ensure another cascade pass happens
240+
ranMask.clear(currentId); // allow re-run in same tick
241+
}
242+
236243
/**
237244
* @brief Change a task's priority.
238245
*/
@@ -331,4 +338,5 @@ class TaskScheduler : public IScheduler {
331338
}
332339
};
333340

334-
#endif // TASK_SCHEDULER_H
341+
342+
#endif // TASK_SCHEDULER_H

0 commit comments

Comments
 (0)