Ejemplo n.º 1
0
static bool
_finalize_timer() {
    timer_read_begin();
    struct timer_info *timer = get_timer_info();
    timer_read_end();
    assert( timer != NULL );

    debug( "Deleting timer callbacks ( timer_callbacks = %p ).", timer->timer_callbacks );

    if ( timer->timer_callbacks != NULL ) {
        for ( dlist_element *e = timer->timer_callbacks->next; e; e = e->next ) {
            xfree( e->data );
        }
        delete_dlist( timer->timer_callbacks );
        timer->timer_callbacks = NULL;
    }
    else {
        error( "All timer callbacks are already deleted or not created yet." );
    }

    timer_write_begin();
    delete_timer_info( timer );
    timer_write_end();

    return true;
}
Ejemplo n.º 2
0
static bool
_init_timer() {
  struct timer_info *timer = get_timer_info(); 

  if ( timer != NULL ) {
    error( "init_timer has been called twice for thread id %ld", timer->thread_id ); 
    return false;
  }
  timer = ( struct timer_info * ) xmalloc( sizeof( *timer ) );
  timer->thread_id = current_thread();
  timer->timer_callbacks = create_dlist();
  timer_write_begin();
  ALLOC_GROW( timer_list.timers, timer_list.timers_nr + 1, timer_list.timers_alloc );
  timer_list.timers[ timer_list.timers_nr++ ] = timer;
  timer_write_end();

  debug( "Initializing timer callbacks ( timer_callbacks = %p ).", timer->timer_callbacks );
  return true;
}