Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0df92c1c851d7c360ec99c9658bc986a233ac843
[simgrid.git] / examples / java / commTime / Slave.java
1 /*
2  * Copyright 2006-2012. The SimGrid Team. All rights reserved. 
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. 
6  */
7
8 package commTime;
9
10 import org.simgrid.msg.*;
11
12 public class Slave extends org.simgrid.msg.Process {
13         public Slave(Host host, String name, String[]args) {
14                 super(host,name,args);
15         } 
16         public void main(String[] args) throws MsgException {
17       if (args.length < 1) {
18          Msg.info("Slave needs 1 argument (its number)");
19          System.exit(1);
20       }
21
22       int num = Integer.valueOf(args[0]).intValue();
23       Msg.info("Receiving on 'slave_"+num+"'");
24       
25       while(true) { 
26          Task task = Task.receive("slave_"+num);        
27          
28          if (task instanceof FinalizeTask) {
29             break;
30          }
31          task.execute();
32        }
33        
34       Msg.info("Received Finalize. I'm done. See you!");
35     }
36 }