| 128 | } |
| 129 | |
| 130 | int modTimersNext(void) |
| 131 | { |
| 132 | modCriticalSectionDeclare; |
| 133 | int next = 60 * 60 * 1000; // an hour |
| 134 | uint32_t now = modMilliseconds(); |
| 135 | modTimer walker; |
| 136 | #if MOD_TASKS |
| 137 | uintptr_t task = modTaskGetCurrent(); |
| 138 | #endif |
| 139 | |
| 140 | modCriticalSectionBegin(); |
| 141 | |
| 142 | for (walker = getModdableAppState(timers); NULL != walker; walker = walker->next) { |
| 143 | if ((walker->flags & kTimerFlagUnscheduled) |
| 144 | #if MOD_TASKS |
| 145 | || (task != walker->task) |
| 146 | #endif |
| 147 | ) |
| 148 | continue; |
| 149 | |
| 150 | int32_t delta = walker->triggerTime - now; |
| 151 | if (delta < next) { |
| 152 | if (delta <= 0) { |
| 153 | modCriticalSectionEnd(); |
| 154 | return 0; |
| 155 | } |
| 156 | next = delta; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | modCriticalSectionEnd(); |
| 161 | |
| 162 | return next; |
| 163 | } |
| 164 | |
| 165 | modTimer modTimerAdd(int firstInterval, int secondInterval, modTimerCallback cb, void *refcon, int refconSize) |
| 166 | { |
no test coverage detected