X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5cffdb73a735193bfeaa5537b0c6e60707ee947e..24904a5d2b3de5c5404f3817e5f01966cbd1a8d2:/src/bindings/java/org/simgrid/msg/Task.java diff --git a/src/bindings/java/org/simgrid/msg/Task.java b/src/bindings/java/org/simgrid/msg/Task.java index 6410bbfcd9..c6098b32fe 100644 --- a/src/bindings/java/org/simgrid/msg/Task.java +++ b/src/bindings/java/org/simgrid/msg/Task.java @@ -1,5 +1,4 @@ -/* Copyright (c) 2006-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2006-2016. The SimGrid Team. 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. */ @@ -50,6 +49,7 @@ public class Task { */ public Task(String name, double flopsAmount, double bytesAmount) { create(name, flopsAmount, bytesAmount); + this.name = name; this.messageSize = bytesAmount; } /** @@ -85,8 +85,7 @@ public class Task { */ private final native void create(String name, double flopsAmount, - double bytesAmount) - throws IllegalArgumentException; + double bytesAmount); /** * The natively implemented method to create a MSG parallel task. * @@ -100,8 +99,7 @@ public class Task { private final native void parallelCreate(String name, Host[]hosts, double[]flopsAmount, - double[]bytesAmount) - throws NullPointerException, IllegalArgumentException; + double[]bytesAmount); /* * * * * * Getters / Setters * * * * * */ @@ -160,23 +158,17 @@ public class Task { */ public native void execute() throws HostFailureException,TaskCancelledException; - /** Bound a computation to a certain load */ - public native void setBound(double load); + /** Changes the maximum CPU utilization of a computation task. Unit is flops/s. */ + public native void setBound(double bound); /** Cancels a task. */ public native void cancel(); /** Deletes a task once the garbage collector reclaims it */ @Override - protected void finalize() { - try { - // Exceptions in finalizers lead to bad situations: - // http://stackoverflow.com/questions/7644556/troubleshooting-a-java-memory-leak-finalization - nativeFinalize(); - bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize() - } catch (Throwable e) { - e.printStackTrace(); - } + protected void finalize() throws Throwable{ + nativeFinalize(); + bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize() } protected native void nativeFinalize(); /* * * * @@ -204,7 +196,7 @@ public class Task { * @throws HostFailureException * @throws TransferFailureException */ - public void send(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException, NativeException { + public void send(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException { send(mailbox, -1); } @@ -213,12 +205,11 @@ public class Task { * * @param mailbox where to send the message * @param timeout - * @exception NativeException if the retrieval fails. * @throws TimeoutException * @throws HostFailureException * @throws TransferFailureException */ - public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException, NativeException; + public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException; /** Sends the task on the specified mailbox (capping the sending rate to \a maxrate) * @@ -259,12 +250,14 @@ public class Task { /** * Starts listening for receiving a task from an asynchronous communication * @param mailbox + * @return a Comm handler */ public static native Comm irecv(String mailbox); /** * Retrieves next task from the mailbox identified by the specified name * * @param mailbox + * @return a Task */ public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException { @@ -276,6 +269,7 @@ public class Task { * * @param mailbox * @param timeout + * @return a Task */ public static Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException { return receive(mailbox, timeout, null); @@ -286,6 +280,7 @@ public class Task { * * @param mailbox * @param host + * @return a Task */ public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException { @@ -298,18 +293,21 @@ public class Task { * @param mailbox * @param timeout * @param host + * @return a Task */ - public native static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException; + public static native Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException; /** * Starts listening for receiving a task from an asynchronous communication with a capped rate * @param mailbox + * @return a Comm handler */ public static native Comm irecvBounded(String mailbox, double rate); /** * Retrieves next task from the mailbox identified by the specified name with a capped rate * * @param mailbox + * @return a Task */ public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException { @@ -321,6 +319,7 @@ public class Task { * * @param mailbox * @param timeout + * @return a Task */ public static Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException { return receiveBounded(mailbox, timeout, null, rate); @@ -331,6 +330,7 @@ public class Task { * * @param mailbox * @param host + * @return a Task */ public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException { @@ -344,24 +344,20 @@ public class Task { * @param mailbox * @param timeout * @param host + * @return a Task */ - public native static Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException; + public static native Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException; /** * Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it */ - public native static int listenFrom(String mailbox); + public static native int listenFrom(String mailbox); /** * Listen whether there is a task waiting (either for a send or a recv) on the mailbox identified by the specified alias */ - public native static boolean listen(String mailbox); - - /** - * Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host. - */ - public native static int listenFromHost(String alias, Host host); + public static native boolean listen(String mailbox); /** * Class initializer, to initialize various JNI stuff