mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-21 16:06:35 +06:00
[Bugfix] Manipulate deferred executor slot only if tokens match (#22722)
This commit is contained in:
parent
3afa2a9439
commit
2661ee282a
|
@ -124,13 +124,19 @@ void deferred_exec_advanced_task(deferred_executor_t *table, size_t table_count,
|
||||||
|
|
||||||
// Run through each of the executors
|
// Run through each of the executors
|
||||||
for (int i = 0; i < table_count; ++i) {
|
for (int i = 0; i < table_count; ++i) {
|
||||||
deferred_executor_t *entry = &table[i];
|
deferred_executor_t *entry = &table[i];
|
||||||
|
deferred_token curr_token = entry->token;
|
||||||
|
|
||||||
// Check if we're supposed to execute this entry
|
// Check if we're supposed to execute this entry
|
||||||
if (entry->token != INVALID_DEFERRED_TOKEN && ((int32_t)TIMER_DIFF_32(entry->trigger_time, now)) <= 0) {
|
if (curr_token != INVALID_DEFERRED_TOKEN && ((int32_t)TIMER_DIFF_32(entry->trigger_time, now)) <= 0) {
|
||||||
// Invoke the callback and work work out if we should be requeued
|
// Invoke the callback and work work out if we should be requeued
|
||||||
uint32_t delay_ms = entry->callback(entry->trigger_time, entry->cb_arg);
|
uint32_t delay_ms = entry->callback(entry->trigger_time, entry->cb_arg);
|
||||||
|
|
||||||
|
// If the token has changed, then the callback has canceled and re-queued. Skip further processing.
|
||||||
|
if (entry->token != curr_token) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the trigger time if we have to repeat, otherwise clear it out
|
// Update the trigger time if we have to repeat, otherwise clear it out
|
||||||
if (delay_ms > 0) {
|
if (delay_ms > 0) {
|
||||||
// Intentionally add just the delay to the existing trigger time -- this ensures the next
|
// Intentionally add just the delay to the existing trigger time -- this ensures the next
|
||||||
|
|
Loading…
Reference in New Issue
Block a user