Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Also remove the pseudo-specific task type for this example (since it's also empty)
[simgrid.git] / examples / java / basic / Slave.java
index f3b6764..d2bb15d 100644 (file)
@@ -12,27 +12,21 @@ import simgrid.msg.*;
 
 public class Slave extends simgrid.msg.Process {
    public void main(String[] args) throws JniException, NativeException {
-      Msg.info("Hello !");
-      
-      Channel channel = new Channel(0);
+      if (args.length < 1) {
+        Msg.info("Slave needs 1 argument (its number)");
+        System.exit(1);
+      }
 
+      int num = Integer.valueOf(args[0]).intValue();
+      Msg.info("Receiving on 'slave_"+num+"'");
+      
       while(true) { 
-        Task t = channel.get();        
+        Task task = Task.receive("slave_"+num);        
         
-        if (t instanceof FinalizeTask) {
+        if (task instanceof FinalizeTask) {
            break;
         }
-        BasicTask task = (BasicTask)t;
-        Msg.info("Received \"" + task.getName() + "\" ");
-        
-        if (task.getData() == 0) {
-           Msg.info("task.getData() gave null \"" + task.getName() + "\" ");
-        } else if(task.getData() == 221297) {
-           break;
-        }
-        
-        Msg.info("Processing \"" + task.getName() +  "\" ");
-        
+        Msg.info("Received \"" + task.getName() +  "\". Processing it.");       
         task.execute();
         Msg.info("\"" + task.getName() + "\" done ");
        }