| 163 | } |
| 164 | |
| 165 | modTimer modTimerAdd(int firstInterval, int secondInterval, modTimerCallback cb, void *refcon, int refconSize) |
| 166 | { |
| 167 | ModdablePebbleAppState state = (ModdablePebbleAppState)app_state_get_js_memory_api_context(); |
| 168 | modCriticalSectionDeclare; |
| 169 | modTimer timer; |
| 170 | |
| 171 | timer = c_malloc(sizeof(modTimerRecord) + refconSize); |
| 172 | if (!timer) return NULL; |
| 173 | |
| 174 | timer->next = NULL; |
| 175 | timer->triggerTime = modMilliseconds() + firstInterval; |
| 176 | timer->repeatInterval = secondInterval; |
| 177 | timer->flags = 0; |
| 178 | timer->useCount = 1; |
| 179 | timer->cb = cb; |
| 180 | #if MOD_TASKS |
| 181 | timer->task = modTaskGetCurrent(); |
| 182 | #endif |
| 183 | timer->refconSize = refconSize; |
| 184 | c_memmove(timer->refcon, refcon, refconSize); |
| 185 | |
| 186 | modCriticalSectionBegin(); |
| 187 | |
| 188 | if (!state->timers) |
| 189 | state->timers = timer; |
| 190 | else { |
| 191 | modTimer walker; |
| 192 | |
| 193 | for (walker = state->timers; walker->next; walker = walker->next) |
| 194 | ; |
| 195 | walker->next = timer; |
| 196 | } |
| 197 | |
| 198 | modCriticalSectionEnd(); |
| 199 | |
| 200 | modInstrumentationAdjust(Timers, +1); |
| 201 | |
| 202 | modTimersScheduleNext(); |
| 203 | |
| 204 | return timer; |
| 205 | } |
| 206 | |
| 207 | void modTimerReschedule(modTimer timer, int firstInterval, int secondInterval) |
| 208 | { |
nothing calls this directly
no test coverage detected