コード例 #1
0
ファイル: pthread-timers.c プロジェクト: JinSeok/GIT_Test
int
timer_delete( timer_t  id )
{
    if ( __likely(!TIMER_ID_IS_WRAPPED(id)) )
        return __timer_delete( id );
    else
    {
        thr_timer_table_t*  table = __timer_table_get();
        thr_timer_t*        timer = thr_timer_table_from_id(table, id, 1);

        if (timer == NULL) {
            errno = EINVAL;
            return -1;
        }

        /* tell the timer's thread to stop */
        thr_timer_lock(timer);
        timer->done = 1;
        pthread_cond_signal( &timer->cond );
        thr_timer_unlock(timer);

        /* NOTE: the thread will call __timer_table_free() to free the
         * timer object. the '1' parameter to thr_timer_table_from_id
         * above ensured that the object and its timer_id cannot be
         * reused before that.
         */
        return 0;
    }
}
コード例 #2
0
ファイル: timer.c プロジェクト: zhaodongxing/turnix
void timer_delete(struct timer *timer)
{
	unsigned long flags = interrupt_disable();

	if (timer->i != TIMER_INVALID_INDEX)
		__timer_delete(timer);
	interrupt_enable(flags);
}
コード例 #3
0
// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html
int timer_delete(timer_t id) {
  int rc = __timer_delete(to_kernel_timer_id(id));
  if (rc == -1) {
    return -1;
  }

  PosixTimer* timer = reinterpret_cast<PosixTimer*>(id);
  if (timer->sigev_notify == SIGEV_THREAD) {
    // Stopping the timer's thread frees the timer data when it's safe.
    __timer_thread_stop(timer);
  } else {
    // For timers without threads, we can just free right away.
    free(timer);
  }

  return 0;
}