+/* Copyright (c) 2010. The SimGrid Team.
+ * All rights reserved. */
+
+/* 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 "ruby_simdag.h"
#include "rb_SD_task.h"
// Free Method
ptr_comm = RARRAY(communication_amount)->ptr;
wrk_list = xbt_new0(SD_workstation_t,wrk_nb);
- comp_amount = xbt_new0(double,wrk_nb);//malloc(sizeof(double)*wrk_nb); //xbt_new0(double,wrk_nb);
- comm_amount = xbt_new0(double,wrk_nb);//malloc(sizeof(double)*wrk_nb); //xbt_new0(double,wrk_nb);
+ comp_amount = xbt_new0(double,wrk_nb);
+ comm_amount = xbt_new0(double,wrk_nb);
// wrk_nb == comp_nb == comm_nb ???
for (i=0;i<wrk_nb;i++)
for (i=0;i<comm_nb;i++)
comm_amount[i] = NUM2DBL(ptr_comm[i]);*/
-
SD_task_schedule(tk,wrk_nb,wrk_list,comp_amount,comm_amount,rt);
xbt_free(wrk_list);
- // FIXME, used later if wanna calculate start & fininsh time for a task
- free(comp_amount);
- free(comm_amount);
+ xbt_free(comp_amount);
+ xbt_free(comm_amount);
}
static VALUE rb_SD_simulate(VALUE class,VALUE how_long)
{
int i;
+ SD_task_t task ;
double hl = NUM2DBL(how_long);
- SD_task_t * tasks = SD_simulate(hl);
+ xbt_dynar_t simulated_tasks = SD_simulate(hl) ;
+
VALUE rb_tasks = rb_ary_new();
- for (i = 0; tasks[i] != NULL; i++)
- {
- VALUE tk = Qnil;
- tk = Data_Wrap_Struct(class, 0, SD_task_free, tasks[i]);
- rb_ary_push(rb_tasks,tk);
-
- }
+ xbt_dynar_foreach(simulated_tasks, i, task){
+ VALUE tk = Qnil;
+ tk = Data_Wrap_Struct(class, 0, SD_task_free, task);
+ rb_ary_push(rb_tasks,tk);
+ }
+
return rb_tasks;
}