Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ruby Msg Binding : new Methods and new Example
[simgrid.git] / src / bindings / ruby / simgrid_ruby.c
index ca4bb74..74fba1d 100644 (file)
@@ -65,20 +65,21 @@ static void msg_run(VALUE class) {
   DEBUG0
   ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
   /* Cleanup Ruby hosts */
   DEBUG0
   ("MSG_main finished. Bail out before cleanup since there is a bug in this part.");
   /* Cleanup Ruby hosts */
-  DEBUG0("Clean Ruby World (TODO) ");
+  DEBUG0("Clean Ruby World  ");
   hosts = MSG_get_host_table();
   host_count = MSG_get_host_number();
   for (cpt=0;cpt<host_count;cpt++) {
     rbHost = (VALUE)((hosts[cpt])->data);
   }
   hosts = MSG_get_host_table();
   host_count = MSG_get_host_number();
   for (cpt=0;cpt<host_count;cpt++) {
     rbHost = (VALUE)((hosts[cpt])->data);
   }
-  
-  //FIXME  Before Cleanin' up , we should stop process running to avoir a ThreadError
- /* if (MSG_OK != MSG_clean()){
-    rb_raise(rb_eRuntimeError,"MSG_clean() failed");
-  }*/
   return;
 }
 
   return;
 }
 
+static void msg_clean(VALUE class)
+{
+   if (MSG_OK != MSG_clean())
+    rb_raise(rb_eRuntimeError,"MSG_clean() failed");
+  
+}
 static void msg_createEnvironment(VALUE class,VALUE plateformFile) {
 
   int type = TYPE(plateformFile);
 static void msg_createEnvironment(VALUE class,VALUE plateformFile) {
 
   int type = TYPE(plateformFile);
@@ -131,7 +132,6 @@ static void msg_debug(VALUE class,VALUE msg) {
 
 // get Clock
 static VALUE msg_get_clock(VALUE class) {
 
 // get Clock
 static VALUE msg_get_clock(VALUE class) {
-
   return rb_float_new(MSG_get_clock());
 
 }
   return rb_float_new(MSG_get_clock());
 
 }
@@ -153,6 +153,7 @@ void Init_simgrid_ruby() {
   rb_define_module_function(rb_msg,"info",(rb_meth)msg_info,1);
   rb_define_module_function(rb_msg,"debug",(rb_meth)msg_debug,1);
   rb_define_module_function(rb_msg,"getClock",(rb_meth)msg_get_clock,0);
   rb_define_module_function(rb_msg,"info",(rb_meth)msg_info,1);
   rb_define_module_function(rb_msg,"debug",(rb_meth)msg_debug,1);
   rb_define_module_function(rb_msg,"getClock",(rb_meth)msg_get_clock,0);
+  rb_define_module_function(rb_msg,"exit",(rb_meth)msg_clean,0);
 
   //Associated Process Methods
   rb_define_method(rb_msg,"processSuspend",(rb_meth)rb_process_suspend,1);
 
   //Associated Process Methods
   rb_define_method(rb_msg,"processSuspend",(rb_meth)rb_process_suspend,1);
@@ -169,6 +170,8 @@ void Init_simgrid_ruby() {
 
   //Task Methods 
   rb_define_module_function(rb_task,"new",(rb_meth)rb_task_new,3);
 
   //Task Methods 
   rb_define_module_function(rb_task,"new",(rb_meth)rb_task_new,3);
+  rb_define_module_function(rb_task,"setData",(rb_meth)rb_task_set_data,2);
+  rb_define_module_function(rb_task,"data",(rb_meth)rb_task_get_data,1);
   rb_define_module_function(rb_task,"compSize",(rb_meth)rb_task_comp,1);
   rb_define_module_function(rb_task,"name",(rb_meth)rb_task_name,1);
   rb_define_module_function(rb_task,"execute",(rb_meth)rb_task_execute,1);
   rb_define_module_function(rb_task,"compSize",(rb_meth)rb_task_comp,1);
   rb_define_module_function(rb_task,"name",(rb_meth)rb_task_name,1);
   rb_define_module_function(rb_task,"execute",(rb_meth)rb_task_execute,1);
@@ -178,6 +181,8 @@ void Init_simgrid_ruby() {
   rb_define_module_function(rb_task,"source",(rb_meth)rb_task_source,1);
   rb_define_module_function(rb_task,"listen",(rb_meth)rb_task_listen,2);
   rb_define_module_function(rb_task,"listenFromHost",(rb_meth)rb_task_listen_host,3);
   rb_define_module_function(rb_task,"source",(rb_meth)rb_task_source,1);
   rb_define_module_function(rb_task,"listen",(rb_meth)rb_task_listen,2);
   rb_define_module_function(rb_task,"listenFromHost",(rb_meth)rb_task_listen_host,3);
+  rb_define_module_function(rb_task,"setPriority",(rb_meth)rb_task_set_priority,2);
+  rb_define_module_function(rb_task,"cancel",(rb_meth)rb_task_cancel,1);
 
   //Host Methods
   rb_define_module_function(rb_host,"getByName",(rb_meth)rb_host_get_by_name,1);
 
   //Host Methods
   rb_define_module_function(rb_host,"getByName",(rb_meth)rb_host_get_by_name,1);
@@ -187,4 +192,5 @@ void Init_simgrid_ruby() {
   rb_define_module_function(rb_host,"setData",(rb_meth)rb_host_set_data,2);
   rb_define_module_function(rb_host,"getData",(rb_meth)rb_host_get_data,1);
   rb_define_module_function(rb_host,"isAvail",(rb_meth)rb_host_is_avail,1);
   rb_define_module_function(rb_host,"setData",(rb_meth)rb_host_set_data,2);
   rb_define_module_function(rb_host,"getData",(rb_meth)rb_host_get_data,1);
   rb_define_module_function(rb_host,"isAvail",(rb_meth)rb_host_is_avail,1);
+  rb_define_module_function(rb_host,"getHostProcess",(rb_meth)rb_host_process,1);
 }
\ No newline at end of file
 }
\ No newline at end of file