MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / modTimersNext

Function modTimersNext

modules/base/timer/pebble/timer.c:130–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130int 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
165modTimer modTimerAdd(int firstInterval, int secondInterval, modTimerCallback cb, void *refcon, int refconSize)
166{

Callers 1

modTimersScheduleNextFunction · 0.70

Calls 1

modMillisecondsFunction · 0.85

Tested by

no test coverage detected