Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Compile fix
[simgrid.git] / src / bindings / ruby / PingPong.rb
index 2281b1d..57adbc4 100644 (file)
@@ -8,14 +8,12 @@ include MSG
 
 class PingPongTask < MSG::Task
   
-
   def initialize(*args)
+  puts "Here is the ping pong initializer"
     #Has No Role, Since Its The Task Class ( Created from C ) tht will be called , 
     # and any instruction here will be ignored
   end
-  
 
-  
 end
 
 ####################
@@ -38,16 +36,17 @@ class Sender < MSG::Process
    end
    
    for i in 0..hostCount-1
-     time = MSG.getClock.to_s # to send as a data >> must be a string
+     time = MSG.getClock
      MSG::info("sender time :"+time.to_s)
      task = PingPongTask.new("PingTask",10000,2000)
+     MSG::info("task created :" + task.name);
      task.setData(time)
      p "mailboxe >>> "+ mailboxes[i]
      task.send(mailboxes[i])
    end
    
-   MSG::info("GoodBye !!!")
-     
+   MSG::info("GoodBye !!!")     
+   
    end
    
  end
@@ -59,17 +58,15 @@ class Sender < MSG::Process
 class Receiver < MSG::Process
   
   def main(args)
-    
     MSG::info("Hello from Receiver")
     time = MSG.getClock
     MSG::info("Try to get a task")
     host = MSG::Host.getHostProcess(self)
     task = PingPongTask.receive(host.name)
     p "task name recevied : "+ task.name
-    p "data in the task :" + task.data
     timeGot = MSG.getClock
-    timeSent= task.data
     MSG::info("Got at time: "+timeGot.to_s)
+    timeSent = task.data
     MSG::info("Was sent at time "+timeSent.to_s)
     communicationTime = timeGot - time
     MSG::info("Communication Time: "+communicationTime.to_s)
@@ -77,7 +74,6 @@ class Receiver < MSG::Process
     MSG::info("GoodBye !!!")
   end
   
-  
 end
 
 #################################################
@@ -90,7 +86,6 @@ if (ARGV.length == 2)
 else 
        MSG.createEnvironment("ping_pong_platform.xml")
        MSG.deployApplication("ping_pong_deployment.xml")
-
 end
 
 MSG.run