Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
autogenerated
[simgrid.git] / examples / java / basic / Forwarder.java
index 2e08701..4e856bc 100644 (file)
@@ -28,36 +28,30 @@ public class Forwarder extends simgrid.msg.Process {
         }
       }
       
-      Channel channel = new Channel(0);
-               
       int taskCount = 0;
       while(true) {
-                       
-        BasicTask task = (BasicTask)channel.get();
+        Task t = Task.get(0);  
         
-        Msg.info("Received \"" + task.getName() + "\" ");
-        
-        if(task.getData() == 221297) {
+        if (t instanceof FinalizeTask) {
            Msg.info("All tasks have been dispatched. Let's tell everybody the computation is over.");
            
            for (int cpt = 0; cpt<slavesCount; cpt++) {
-              BasicTask forwardedtask = new BasicTask("finalize", 0, 0);
-              forwardedtask.setData(221297);
-              
-              channel.put(forwardedtask,slaves[cpt]);
+              slaves[cpt].put(0,new FinalizeTask());
            }
            break;
-           
-        } else {
-           
-           Msg.info("Sending \"" + task.getName() + "\" to \"" + slaves[taskCount % slavesCount].getName() + "\"");
-           channel.put(task, slaves[taskCount % slavesCount]);
-           
-           taskCount++;
         }
+        BasicTask task = (BasicTask)t;
         
-        Msg.info("I'm done. See you!");
+        Msg.info("Received \"" + task.getName() + "\" ");
+                   
+        Msg.info("Sending \"" + task.getName() + "\" to \"" + slaves[taskCount % slavesCount].getName() + "\"");
+        slaves[taskCount % slavesCount].put(0, task);
+           
+        taskCount++;
       }
+      
+        
+      Msg.info("I'm done. See you!");
    }
 }