| 50 | } |
| 51 | |
| 52 | int multiTimerYield(void) { |
| 53 | if (platformTicksFunction == NULL) { |
| 54 | return -1; // Indicate error if platformTicksFunction is NULL |
| 55 | } |
| 56 | uint64_t currentTicks = platformTicksFunction(); |
| 57 | while (timerList && (currentTicks >= timerList->deadline)) { |
| 58 | MultiTimer* timer = timerList; |
| 59 | timerList = timer->next; // Remove expired timer |
| 60 | |
| 61 | if (timer->callback) { |
| 62 | timer->callback(timer, timer->userData); // Execute callback |
| 63 | } |
| 64 | } |
| 65 | return timerList ? (int)(timerList->deadline - currentTicks) : 0; |
| 66 | } |