Lines Matching refs:timer
39 HANDLE timer; member
44 const deTimer* timer = (const deTimer*)lpParameter; in timerCallback() local
47 timer->callback(timer->callbackArg); in timerCallback()
52 deTimer* timer = (deTimer*)deCalloc(sizeof(deTimer)); in deTimer_create() local
54 if (!timer) in deTimer_create()
57 timer->callback = callback; in deTimer_create()
58 timer->callbackArg = arg; in deTimer_create()
59 timer->timer = 0; in deTimer_create()
61 return timer; in deTimer_create()
64 void deTimer_destroy (deTimer* timer) in deTimer_destroy() argument
66 DE_ASSERT(timer); in deTimer_destroy()
68 if (deTimer_isActive(timer)) in deTimer_destroy()
69 deTimer_disable(timer); in deTimer_destroy()
71 deFree(timer); in deTimer_destroy()
74 deBool deTimer_isActive (const deTimer* timer) in deTimer_isActive() argument
76 return timer->timer != 0; in deTimer_isActive()
79 deBool deTimer_scheduleSingle (deTimer* timer, int milliseconds) in deTimer_scheduleSingle() argument
83 DE_ASSERT(timer && milliseconds > 0); in deTimer_scheduleSingle()
85 if (deTimer_isActive(timer)) in deTimer_scheduleSingle()
88 …ret = CreateTimerQueueTimer(&timer->timer, NULL, timerCallback, timer, (DWORD)milliseconds, 0, WT_… in deTimer_scheduleSingle()
92 DE_ASSERT(!timer->timer); in deTimer_scheduleSingle()
99 deBool deTimer_scheduleInterval (deTimer* timer, int milliseconds) in deTimer_scheduleInterval() argument
103 DE_ASSERT(timer && milliseconds > 0); in deTimer_scheduleInterval()
105 if (deTimer_isActive(timer)) in deTimer_scheduleInterval()
108 …ret = CreateTimerQueueTimer(&timer->timer, NULL, timerCallback, timer, (DWORD)milliseconds, (DWORD… in deTimer_scheduleInterval()
112 DE_ASSERT(!timer->timer); in deTimer_scheduleInterval()
119 void deTimer_disable (deTimer* timer) in deTimer_disable() argument
121 if (timer->timer) in deTimer_disable()
130 BOOL success = DeleteTimerQueueTimer(NULL, timer->timer, waitEvent); in deTimer_disable()
151 timer->timer = 0; in deTimer_disable()
165 timer_t timer; member
172 const deTimer* timer = (const deTimer*)val.sival_ptr; in timerCallback() local
173 timer->callback(timer->callbackArg); in timerCallback()
178 deTimer* timer = (deTimer*)deCalloc(sizeof(deTimer)); in deTimer_create() local
181 if (!timer) in deTimer_create()
186 sevp.sigev_value.sival_ptr = timer; in deTimer_create()
189 if (timer_create(CLOCK_REALTIME, &sevp, &timer->timer) != 0) in deTimer_create()
191 deFree(timer); in deTimer_create()
195 timer->callback = callback; in deTimer_create()
196 timer->callbackArg = arg; in deTimer_create()
197 timer->isActive = DE_FALSE; in deTimer_create()
199 return timer; in deTimer_create()
202 void deTimer_destroy (deTimer* timer) in deTimer_destroy() argument
204 DE_ASSERT(timer); in deTimer_destroy()
206 timer_delete(timer->timer); in deTimer_destroy()
207 deFree(timer); in deTimer_destroy()
210 deBool deTimer_isActive (const deTimer* timer) in deTimer_isActive() argument
212 return timer->isActive; in deTimer_isActive()
215 deBool deTimer_scheduleSingle (deTimer* timer, int milliseconds) in deTimer_scheduleSingle() argument
219 DE_ASSERT(timer && milliseconds > 0); in deTimer_scheduleSingle()
221 if (timer->isActive) in deTimer_scheduleSingle()
229 if (timer_settime(timer->timer, 0, &tspec, DE_NULL) != 0) in deTimer_scheduleSingle()
232 timer->isActive = DE_TRUE; in deTimer_scheduleSingle()
236 deBool deTimer_scheduleInterval (deTimer* timer, int milliseconds) in deTimer_scheduleInterval() argument
240 DE_ASSERT(timer && milliseconds > 0); in deTimer_scheduleInterval()
242 if (timer->isActive) in deTimer_scheduleInterval()
250 if (timer_settime(timer->timer, 0, &tspec, DE_NULL) != 0) in deTimer_scheduleInterval()
253 timer->isActive = DE_TRUE; in deTimer_scheduleInterval()
257 void deTimer_disable (deTimer* timer) in deTimer_disable() argument
261 DE_ASSERT(timer); in deTimer_disable()
268 timer_settime(timer->timer, 0, &tspec, DE_NULL); in deTimer_disable()
272 timer->isActive = DE_FALSE; in deTimer_disable()
383 deTimer* timer = (deTimer*)deCalloc(sizeof(deTimer)); in deTimer_create() local
385 if (!timer) in deTimer_create()
388 timer->callback = callback; in deTimer_create()
389 timer->callbackArg = arg; in deTimer_create()
391 return timer; in deTimer_create()
394 void deTimer_destroy (deTimer* timer) in deTimer_destroy() argument
396 if (timer->curThread) in deTimer_destroy()
397 deTimer_disable(timer); in deTimer_destroy()
398 deFree(timer); in deTimer_destroy()
401 deBool deTimer_isActive (const deTimer* timer) in deTimer_isActive() argument
403 if (timer->curThread) in deTimer_isActive()
407 deMutex_lock(timer->curThread->lock); in deTimer_isActive()
408 isActive = timer->curThread->state != TIMERSTATE_LAST; in deTimer_isActive()
409 deMutex_unlock(timer->curThread->lock); in deTimer_isActive()
417 deBool deTimer_scheduleSingle (deTimer* timer, int milliseconds) in deTimer_scheduleSingle() argument
419 if (timer->curThread) in deTimer_scheduleSingle()
420 deTimer_disable(timer); in deTimer_scheduleSingle()
422 DE_ASSERT(!timer->curThread); in deTimer_scheduleSingle()
423 …timer->curThread = deTimerThread_create(timer->callback, timer->callbackArg, milliseconds, TIMERST… in deTimer_scheduleSingle()
425 return timer->curThread != DE_NULL; in deTimer_scheduleSingle()
428 deBool deTimer_scheduleInterval (deTimer* timer, int milliseconds) in deTimer_scheduleInterval() argument
430 if (timer->curThread) in deTimer_scheduleInterval()
431 deTimer_disable(timer); in deTimer_scheduleInterval()
433 DE_ASSERT(!timer->curThread); in deTimer_scheduleInterval()
434 …timer->curThread = deTimerThread_create(timer->callback, timer->callbackArg, milliseconds, TIMERST… in deTimer_scheduleInterval()
436 return timer->curThread != DE_NULL; in deTimer_scheduleInterval()
439 void deTimer_disable (deTimer* timer) in deTimer_disable() argument
441 if (!timer->curThread) in deTimer_disable()
444 deMutex_lock(timer->curThread->lock); in deTimer_disable()
446 if (timer->curThread->state != TIMERSTATE_DISABLED) in deTimer_disable()
452 timer->curThread->state = TIMERSTATE_DISABLED; in deTimer_disable()
453 deThread_destroy(timer->curThread->thread); in deTimer_disable()
454 timer->curThread->thread = 0; in deTimer_disable()
455 deMutex_unlock(timer->curThread->lock); in deTimer_disable()
462 deMutex_unlock(timer->curThread->lock); in deTimer_disable()
463 deThread_destroy(timer->curThread->thread); in deTimer_disable()
464 deMutex_destroy(timer->curThread->lock); in deTimer_disable()
465 deFree(timer->curThread); in deTimer_disable()
468 timer->curThread = DE_NULL; in deTimer_disable()