Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Gras listener thread of each process do select(-1) instead of while(1) {select(0.5)}
[simgrid.git] / src / gras / Msg / timer.c
index 6162502..49c0f1b 100644 (file)
@@ -45,7 +45,8 @@ void gras_timer_repeat(double interval, void_f_void_t action) {
 /** @brief Cancel a delayed task */
 void gras_timer_cancel_delay(double interval, void_f_void_t action) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
-  int cursor,found;
+  unsigned int cursor;
+  int found;
   s_gras_timer_t timer;
 
   found = FALSE;
@@ -68,7 +69,8 @@ void gras_timer_cancel_delay(double interval, void_f_void_t action) {
 /** @brief Cancel a repetitive task */
 void gras_timer_cancel_repeat(double interval, void_f_void_t action) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
-  int cursor,found;
+  unsigned int cursor;
+  int found;
   s_gras_timer_t timer;
 
   found = FALSE;
@@ -90,7 +92,8 @@ void gras_timer_cancel_repeat(double interval, void_f_void_t action) {
 /** @brief Cancel all delayed tasks */
 void gras_timer_cancel_delay_all(void) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
-  int cursor, found;
+  unsigned int cursor;
+  int found;
   s_gras_timer_t timer;
 
   found = FALSE;
@@ -110,7 +113,8 @@ void gras_timer_cancel_delay_all(void) {
 /** @brief Cancel all repetitive tasks */
 void gras_timer_cancel_repeat_all(void){
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
-  int cursor, found;
+  unsigned int cursor;
+  int found;
   s_gras_timer_t timer;
 
   found = FALSE;
@@ -136,7 +140,7 @@ void gras_timer_cancel_all(void) {
 /* returns 0 if it handled a timer, or the delay until next timer, or -1 if no armed timer */
 double gras_msg_timer_handle(void) {
   gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
-  int cursor;
+  unsigned int cursor;
   gras_timer_t timer;
   double now=gras_os_time();
   double untilnext = -1.0;
@@ -150,7 +154,7 @@ double gras_msg_timer_handle(void) {
      DEBUG2("Action %p expires in %f", timer->action, untilthis);
      
      if (untilthis <= 0.0) {
-       void_f_void_t *action = timer->action;
+       void_f_void_t action = timer->action;
        
        DEBUG5("[%.0f] Serve %s action %p (%f<%f)",gras_os_time(),
              timer->repeat ? "repetitive" : "delayed", timer->action,
@@ -165,7 +169,7 @@ double gras_msg_timer_handle(void) {
         DEBUG2("[%.0f] Remove %p now that it's done", gras_os_time(), timer->action);
         xbt_dynar_cursor_rm(pd->timers, &cursor);
        }
-       action();
+       (*action)();
        return 0.0;
      } else if (untilthis < untilnext || untilnext == -1) {
        untilnext = untilthis;