| 102 | } |
| 103 | |
| 104 | int modTimersNext(void) |
| 105 | { |
| 106 | modCriticalSectionDeclare; |
| 107 | int next = 60 * 60 * 1000; // an hour |
| 108 | uint32_t now = modMilliseconds(); |
| 109 | modTimer walker; |
| 110 | #if MOD_TASKS |
| 111 | uintptr_t task = modTaskGetCurrent(); |
| 112 | #endif |
| 113 | |
| 114 | modCriticalSectionBegin(); |
| 115 | |
| 116 | for (walker = gTimers; NULL != walker; walker = walker->next) { |
| 117 | if ((walker->flags & kTimerFlagUnscheduled) |
| 118 | #if MOD_TASKS |
| 119 | || (task != walker->task) |
| 120 | #endif |
| 121 | ) |
| 122 | continue; |
| 123 | |
| 124 | int32_t delta = walker->triggerTime - now; |
| 125 | if (delta < next) { |
| 126 | if (delta <= 0) { |
| 127 | modCriticalSectionEnd(); |
| 128 | return 0; |
| 129 | } |
| 130 | next = delta; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | modCriticalSectionEnd(); |
| 135 | |
| 136 | return next; |
| 137 | } |
| 138 | |
| 139 | modTimer modTimerAdd(int firstInterval, int secondInterval, modTimerCallback cb, void *refcon, int refconSize) |
| 140 | { |
no test coverage detected