Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
One more FIXME to achieve for code simplification
[simgrid.git] / src / bindings / ruby / rb_msg_process.c
index 505b8a2..0666340 100644 (file)
@@ -30,7 +30,6 @@ VALUE rb_process_getBind(VALUE ruby_process) {
   return rb_funcall(ruby_process,rb_intern("getBind"),0);
 }
 
-
 // Set Bind
 void rb_process_setBind(VALUE ruby_process,long bind) {
   VALUE r_bind = LONG2FIX(bind);
@@ -52,6 +51,7 @@ void rb_process_join( VALUE ruby_process ) {
   rb_funcall(ruby_process,rb_intern("join"),0);
 }
 
+// FIXME: all this calls must be manually inlined I guess
 // unschedule Process
 void rb_process_unschedule( VALUE ruby_process ) {
   rb_funcall(ruby_process,rb_intern("unschedule"),0);
@@ -63,12 +63,10 @@ void rb_process_schedule( VALUE ruby_process ) {
 }
 
 /***************************************************
-
 Function for Native Process ( Bound ) Management
 
 Methods Belong to MSG Module
-
- ****************************************************/
+****************************************************/
 
 // Process To Native
 m_process_t rb_process_to_native(VALUE ruby_process) {
@@ -88,76 +86,6 @@ void rb_process_bind(VALUE ruby_process,m_process_t process) {
 }
 
 
-// processCreate
-
-void rb_process_create(VALUE class,VALUE ruby_process,VALUE host) {
-  VALUE rbName;      // Name of Java Process instance
-  m_process_t process; // Native Process to Create
-  const char * name ; // Name of C Native Process
-  char alias[MAX_ALIAS_NAME + 1 ] = {0};
-  msg_mailbox_t mailbox;
-  rbName = rb_process_getName(ruby_process);
-
-  if(!rbName) {
-    rb_raise(rb_eRuntimeError,"Internal error : Process Name Cannot be NULL");
-    return;
-  }
-  // Allocate the data for the simulation
-  process = xbt_new0(s_m_process_t,1);
-  process->simdata = xbt_new0(s_simdata_process_t,1);
-  // Do we Really Need to Create Ruby Process Instance , >> process is already a Ruby Process !! So..Keep on ;)
-  // Bind The Ruby Process instance to The Native Process
-  rb_process_bind(ruby_process,process);
-  name = RSTRING(rbName)->ptr;
-  process->name = xbt_strdup(name);
-  Data_Get_Struct(host,s_m_host_t,process->simdata->m_host);
-
-  if(!(process->simdata->m_host)) // Not Binded
-  {
-    free(process->simdata);
-    free(process->data);
-    free(process);
-    rb_raise(rb_eRuntimeError,"Host not bound...while creating native process");
-    return;
-  }
-  process->simdata->PID = msg_global->PID++; //  msg_global ??
-
-  DEBUG7("fill in process %s/%s (pid=%d) %p (sd=%p , host=%p, host->sd=%p)",
-      process->name , process->simdata->m_host->name,process->simdata->PID,
-      process,process->simdata, process->simdata->m_host,
-      process->simdata->m_host->simdata);
-
-  /* FIXME: that's mainly for debugging. We could only allocate this if XBT_LOG_ISENABLED(ruby,debug) is true since I guess this leaks */
-  char **argv=xbt_new(char*,2);
-  argv[0] = bprintf("%s@%s",process->name,process->simdata->m_host->simdata->smx_host->name);
-  argv[1] = NULL;
-  process->simdata->s_process =
-      SIMIX_process_create(process->name,
-          (xbt_main_func_t)ruby_process,
-          (void *) process,
-          process->simdata->m_host->simdata->smx_host->name,
-          1,argv,NULL);
-
- DEBUG1("context created (s_process=%p)",process->simdata->s_process);
-
-  if (SIMIX_process_self()) { // SomeOne Created Me !!
-    process->simdata->PPID = MSG_process_get_PID(SIMIX_process_self()->data);
-  }
-  else
-  {
-    process->simdata->PPID = -1;
-  }
-  process->simdata->last_errno = MSG_OK;
-  // let's Add the Process to the list of the Simulation's Processes
-  xbt_fifo_unshift(msg_global->process_list,process);
-  sprintf(alias,"%s:%s",(process->simdata->m_host->simdata->smx_host)->name,
-      process->name);
-
-  mailbox = MSG_mailbox_new(alias);
-
-}
-
-
 // Process Management
 void rb_process_suspend(VALUE class,VALUE ruby_process) {
 
@@ -192,7 +120,6 @@ VALUE rb_process_isSuspended(VALUE class,VALUE ruby_process) {
     rb_raise (rb_eRuntimeError,"Process not Bound...while testing if suspended");
     return Qfalse;
   }
-
   if(MSG_process_is_suspended(process))
     return Qtrue;
   return Qfalse;
@@ -214,20 +141,24 @@ void rb_process_kill_down(VALUE class,VALUE ruby_process) {
 VALUE rb_process_getHost(VALUE class,VALUE ruby_process) {
   m_process_t process = rb_process_to_native(ruby_process);
   m_host_t host;
+  
 
   if (!process) {
     rb_raise(rb_eRuntimeError,"Process Not Bound...while getting Host");
     return Qnil; // NULL
   }
-
+  
   host = MSG_process_get_host(process);
-
+  
+  return Data_Wrap_Struct(class, 0, rb_host_free, host);
+  /*if(host->data) printf("Ok\n"); 
   if(!host->data) {
     rb_raise (rb_eRuntimeError,"MSG_process_get_host() failed");
     return Qnil;
   }
-
-  return Data_Wrap_Struct(class, 0, rb_host_free, host);
+  printf("Houuuuuuuuuuuuuuna3!!\n");
+  return Data_Wrap_Struct(class, 0, rb_host_free, host);*/
 }
 
 void rb_process_exit(VALUE class,VALUE ruby_process) {