/* 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 "surf_timer_private.h"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(timer, surf,
- "Logging specific to the SURF timer module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_timer, surf,
+ "Logging specific to SURF (timer)");
surf_timer_resource_t surf_timer_resource = NULL;
static tmgr_trace_t empty_trace = NULL;
static xbt_swag_t command_pending = NULL;
static xbt_swag_t command_to_run = NULL;
+static xbt_heap_t timer_heap = NULL;
static void timer_free(void *timer)
{
static double share_resources(double now)
{
- return -1.0;
+ if (xbt_heap_size(timer_heap))
+ return (xbt_heap_maxkey(timer_heap));
+ else
+ return -1.0;
}
static void update_actions_state(double now, double delta)
{
+ if(xbt_heap_size(timer_heap)) {
+ if(xbt_heap_maxkey(timer_heap)<=now+delta) {
+ xbt_heap_pop(timer_heap);
+ }
+ }
return;
}
command = command_new(function, arg);
tmgr_history_add_trace(history, empty_trace, date, 0, command);
+ xbt_heap_push(timer_heap, NULL , date);
}
static void finalize(void)
{
+ xbt_heap_free(timer_heap);
+ timer_heap = NULL;
+
+ tmgr_trace_free(empty_trace);
+ empty_trace = NULL;
+
xbt_swag_free(command_pending);
xbt_swag_free(command_to_run);
}
empty_trace = tmgr_empty_trace_new();
+ timer_heap = xbt_heap_new(8, NULL);
xbt_assert0(maxmin_system, "surf_init has to be called first!");
}