1 /* Copyright (c) 2012-2014. The SimGrid Team.
2 * All rights reserved. */
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. */
7 package org.simgrid.msg;
9 /** Communication action, representing an ongoing communication between processes. */
11 /** Indicates if the communication is a receiving communication */
12 protected boolean receiving;
13 /** Indicates if the communication is finished */
14 protected boolean finished = false;
16 * Represents the bind between the java comm and the
17 * native C comm. You must never access it, since it is
20 private long bind = 0;
21 /** Represents the bind for the task object pointer. Don't touch it. */
22 private long taskBind = 0;
23 /** Task associated with the comm. Beware, it can be null */
24 protected Task task = null;
26 * Protected constructor, used by Comm factories
32 /** Destroy the C communication object, when the GC reclaims the java part. */
34 protected void finalize() throws Throwable{
37 protected native void nativeFinalize();
39 * Returns if the communication is finished or not.
40 * If the communication has finished and there was an error,
43 public native boolean test() throws TransferFailureException, HostFailureException, TimeoutException ;
44 /** Wait infinitely for the completion of the communication (infinite timeout) */
45 public void waitCompletion() throws TransferFailureException, HostFailureException, TimeoutException {
49 * Wait for the completion of the communication.
50 * Throws an exception if there were an error in the communication.
51 * @param timeout Time before giving up (infinite time if negative)
53 public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
55 /** Wait all of the communications */
56 public static native void waitAll(Comm[] comms, double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
57 /** Wait all of the communications, with no maximal delay */
58 public static void waitAll(Comm[] comms) throws TransferFailureException, HostFailureException, TimeoutException {
61 /** Wait any of the communications, and return the rank of the terminating comm */
62 public static native void waitAny(Comm[] comms) throws TransferFailureException, HostFailureException, TimeoutException;
64 * Returns the task associated with the communication.
65 * if the communication isn't finished yet, will return null.
67 public Task getTask() {
71 /** Class initializer, to initialize various JNI stuff */
72 public static native void nativeInit();
74 org.simgrid.NativeLib.nativeInit();