- int num = Integer.valueOf(args[0]).intValue();
- Comm comm = null;
- boolean slaveFinished = false;
- while(!slaveFinished) {
- try
- {
- if (comm == null) {
- Msg.info("Receiving on 'slave_" + num + "'");
- comm = Task.irecv("slave_" + num);
- }
- else {
- if (comm.test()) {
- Task task = comm.getTask();
-
- if (task instanceof FinalizeTask) {
- comm = null;
- break;
- }
- Msg.info("Received a task");
- Msg.info("Received \"" + task.getName() + "\". Processing it.");
- try {
- task.execute();
- } catch (TaskCancelledException e) {
-
- }
- comm = null;
- }
- else {
- waitFor(1);
- }
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- Msg.info("Received Finalize. I'm done. See you!");
- waitFor(20);
- }
+ if (task instanceof FinalizeTask) {
+ comm = null;
+ break;
+ }
+ Msg.info("Received a task");
+ Msg.info("Received \"" + task.getName() + "\". Processing it.");
+ try {
+ task.execute();
+ } catch (TaskCancelledException e) {
+
+ }
+ comm = null;
+ } else {
+ waitFor(1);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ Msg.info("Received Finalize. I'm done. See you!");
+ waitFor(20);
+ }