From 94e383e3943b66c348b63c045df75efdc4978965 Mon Sep 17 00:00:00 2001 From: mquinson Date: Sat, 27 Oct 2007 09:44:36 +0000 Subject: [PATCH 1/1] Better Java philosophy: create a new type of tasks to mean terminaison instead of relying of some magic value of the classical computation task (plus reduce the verbosity of the slaves) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4903 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/java/comm_time/FinalizeTask.java | 19 +++++++++++++++++++ examples/java/comm_time/Master.java | 3 +-- examples/java/comm_time/Slave.java | 20 +++++++++----------- 3 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 examples/java/comm_time/FinalizeTask.java diff --git a/examples/java/comm_time/FinalizeTask.java b/examples/java/comm_time/FinalizeTask.java new file mode 100644 index 0000000000..6fd6623a6c --- /dev/null +++ b/examples/java/comm_time/FinalizeTask.java @@ -0,0 +1,19 @@ +/* + * $Id: CommTimeTask.java 3685 2007-07-08 21:02:03Z mquinson $ + * + * Copyright 2006,2007 Martin Quinson, Malek Cherier + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. + */ + +import simgrid.msg.*; + +public class FinalizeTask extends Task { + + public FinalizeTask() throws JniException, NativeException{ + create("",0,0); + } +} + \ No newline at end of file diff --git a/examples/java/comm_time/Master.java b/examples/java/comm_time/Master.java index a9dad92f93..f33c6c6dad 100644 --- a/examples/java/comm_time/Master.java +++ b/examples/java/comm_time/Master.java @@ -53,8 +53,7 @@ public class Master extends simgrid.msg.Process { for (int i = 0; i < slavecount; i++) { - CommTimeTask task = new CommTimeTask("finalize_" + i,0,0); - task.setData(221297); + FinalizeTask task = new FinalizeTask(); Msg.info("Send task to host : " + slaves[i].getName()); channel.put(task,slaves[i]); diff --git a/examples/java/comm_time/Slave.java b/examples/java/comm_time/Slave.java index 086a1928ab..7c622a6359 100644 --- a/examples/java/comm_time/Slave.java +++ b/examples/java/comm_time/Slave.java @@ -20,24 +20,22 @@ public class Slave extends simgrid.msg.Process { while(true) { int a; - double time1,time2; - - time1 = Msg.getClock(); - - CommTimeTask task = (CommTimeTask)channel.get(); - time2 = Msg.getClock(); - - if(task.getData() == 221297) { - Msg.info("Received " + task.getName() + " " + getHost().getName()); + double time1 = Msg.getClock(); + Task t = channel.get(); + double time2 = Msg.getClock(); + + if (t instanceof FinalizeTask) { + Msg.info("Received Finalize " + getHost().getName()); break; } + CommTimeTask task = (CommTimeTask)t; if(time1 < task.getTime()) time1 = task.getTime(); - Msg.info("Processing \"" + task.getName() + "\" " + getHost().getName() + +/* Msg.info("Processing \"" + task.getName() + "\" " + getHost().getName() + " (Communication time : " + (time2 - time1) + ")"); - +*/ task.execute(); -- 2.20.1