4 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(tesh);
7 timer_start_routine(void* p);
10 timer_new(command_t command)
12 ttimer_t timer = xbt_new0(s_timer_t, 1);
14 timer->command = command;
17 timer->started = xbt_os_sem_init(0);
23 timer_free(ttimer_t* timer)
30 timer_time(ttimer_t timer)
32 timer->thread = xbt_os_thread_create("", timer_start_routine, timer);
36 timer_start_routine(void* p)
38 ttimer_t timer = (ttimer_t)p;
39 command_t command = timer->command;
41 int now = (int)time(NULL);
42 int lead_time = now + command->context->timeout;
44 xbt_os_sem_release(timer->started);
46 while(!command->failed && !command->interrupted && !command->successeded && !timer->timeouted)
50 xbt_os_thread_yield();
52 now = (int)time(NULL);
56 /*printf("the timer is timeouted\n");*/
61 if(timer->timeouted && !command->failed && !command->successeded && !command->interrupted)
63 command_handle_failure(command, csr_timeout);
64 command_kill(command);
73 timer_wait(ttimer_t timer)
75 xbt_os_thread_join(timer->thread, NULL);