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 ");
}