Lines Matching defs:thread
275 /* Generic thread-based implementation for OSes that lack proper timers. */
295 deThread thread; /*!< Thread. */
306 deTimerThread* curThread; /*!< Current timer thread. */
311 deTimerThread* thread = (deTimerThread*)arg;
320 deMutex_lock(thread->lock);
322 if (thread->state == TIMERSTATE_SINGLE && numCallbacks > 0)
325 thread->state = TIMERSTATE_DISABLED;
328 else if (thread->state == TIMERSTATE_DISABLED)
331 deMutex_unlock(thread->lock);
333 sleepTime = thread->interval - (int)(((deInt64)deGetMicroseconds()-lastCallback)/1000);
338 thread->callback(thread->callbackArg);
343 deMutex_unlock(thread->lock);
347 /* Destroy thread except thread->thread. */
348 deMutex_destroy(thread->lock);
349 deFree(thread);
355 deTimerThread* thread = (deTimerThread*)deCalloc(sizeof(deTimerThread));
359 if (!thread)
362 thread->callback = callback;
363 thread->callbackArg = arg;
364 thread->interval = interval;
365 thread->lock = deMutex_create(DE_NULL);
366 thread->state = state;
368 thread->thread = deThread_create(timerThread, thread, DE_NULL);
369 if (!thread->thread)
371 deMutex_destroy(thread->lock);
372 deFree(thread);
376 return thread;
446 /* Just set state to disabled and destroy thread handle. */
447 /* \note Assumes that deThread_destroy() can be called while thread is still running
448 * and it will not terminate the thread.
451 deThread_destroy(timer->curThread->thread);
452 timer->curThread->thread = 0;
455 /* Thread will destroy timer->curThread. */
459 /* Single timer has expired - we must destroy whole thread structure. */
461 deThread_destroy(timer->curThread->thread);