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

Function modTimersNext

modules/base/timer/mc/timer.c:104–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104int 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
139modTimer modTimerAdd(int firstInterval, int secondInterval, modTimerCallback cb, void *refcon, int refconSize)
140{

Callers 1

workerLoopFunction · 0.50

Calls 1

modMillisecondsFunction · 0.85

Tested by

no test coverage detected