| 137 | } |
| 138 | |
| 139 | modTimer modTimerAdd(int firstInterval, int secondInterval, modTimerCallback cb, void *refcon, int refconSize) |
| 140 | { |
| 141 | modCriticalSectionDeclare; |
| 142 | modTimer timer; |
| 143 | |
| 144 | timer = c_malloc(sizeof(modTimerRecord) + refconSize - 1); |
| 145 | if (!timer) return NULL; |
| 146 | |
| 147 | timer->next = NULL; |
| 148 | timer->triggerTime = modMilliseconds() + firstInterval; |
| 149 | timer->repeatInterval = secondInterval; |
| 150 | timer->flags = 0; |
| 151 | timer->useCount = 1; |
| 152 | timer->cb = cb; |
| 153 | #if MOD_TASKS |
| 154 | timer->task = modTaskGetCurrent(); |
| 155 | #endif |
| 156 | timer->refconSize = refconSize; |
| 157 | c_memmove(timer->refcon, refcon, refconSize); |
| 158 | |
| 159 | modCriticalSectionBegin(); |
| 160 | |
| 161 | if (!gTimers) |
| 162 | gTimers = timer; |
| 163 | else { |
| 164 | modTimer walker; |
| 165 | |
| 166 | for (walker = gTimers; walker->next; walker = walker->next) |
| 167 | ; |
| 168 | walker->next = timer; |
| 169 | } |
| 170 | |
| 171 | modCriticalSectionEnd(); |
| 172 | |
| 173 | modInstrumentationAdjust(Timers, +1); |
| 174 | |
| 175 | return timer; |
| 176 | } |
| 177 | |
| 178 | void modTimerReschedule(modTimer timer, int firstInterval, int secondInterval) |
| 179 | { |
no test coverage detected