/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-
+#include "xbt/ex.h"
#include "gras/Msg/msg_private.h"
#include "gras/timer.h"
#include "gras/Virtu/virtu_interface.h"
/** @brief Request \a action to be called once in \a delay seconds */
void gras_timer_delay(double delay, void_f_void_t action) {
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+ gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
gras_timer_t timer = xbt_dynar_push_ptr(pd->timers);
/** @brief Request \a action to be called every \a interval seconds */
void gras_timer_repeat(double interval, void_f_void_t action) {
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+ gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
gras_timer_t timer = xbt_dynar_push_ptr(pd->timers);
}
/** @brief Cancel a delayed task */
-xbt_error_t gras_timer_cancel_delay(double interval, void_f_void_t action) {
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+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;
s_gras_timer_t timer;
}
if (!found)
- RAISE2(mismatch_error,"Cannot remove the action %p delayed of %f second: not found",
+ THROW2(mismatch_error,0,"Cannot remove the action %p delayed of %f second: not found",
action,interval);
- return no_error;
}
/** @brief Cancel a repetitive task */
-xbt_error_t gras_timer_cancel_repeat(double interval, void_f_void_t action) {
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+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;
s_gras_timer_t timer;
}
if (!found)
- RAISE2(mismatch_error,"Cannot remove the action %p delayed of %f second: not found",
+ THROW2(mismatch_error,0,"Cannot remove the action %p delayed of %f second: not found",
action,interval);
-
- return no_error;
}
/** @brief Cancel all delayed tasks */
-xbt_error_t gras_timer_cancel_delay_all(void) {
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+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;
s_gras_timer_t timer;
}
if (!found)
- RAISE0(mismatch_error,"No delayed action to remove");
+ THROW0(mismatch_error,0,"No delayed action to remove");
- return no_error;
}
/** @brief Cancel all repetitive tasks */
-xbt_error_t gras_timer_cancel_repeat_all(void){
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+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;
s_gras_timer_t timer;
found = FALSE;
xbt_dynar_foreach(pd->timers,cursor,timer){
- if (timer.repeat == FALSE) {
-
- found = TRUE;
- xbt_dynar_cursor_rm(pd->timers, &cursor);
- }
+ if (timer.repeat == FALSE) {
+
+ found = TRUE;
+ xbt_dynar_cursor_rm(pd->timers, &cursor);
+ }
}
if (!found)
- RAISE0(mismatch_error,"No repetitive action to remove");
-
- return no_error;
+ THROW0(mismatch_error,0,"No repetitive action to remove");
}
/** @brief Cancel all delayed and repetitive tasks */
void gras_timer_cancel_all(void) {
- gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_get("gras_msg");
+ gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
xbt_dynar_reset( pd->timers );
}
/* 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_get("gras_msg");
+ gras_msg_procdata_t pd=(gras_msg_procdata_t)gras_libdata_by_id(gras_msg_libdata_id);
int cursor;
gras_timer_t timer;
double now=gras_os_time();