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;
10 * Communication action, representing an ongoing communication
14 /** Indicates if the communication is a receiving communication */
15 protected boolean receiving;
16 /** Indicates if the communication is finished */
17 protected boolean finished = false;
19 * Represents the bind between the java comm and the
20 * native C comm. You must never access it, since it is
23 private long bind = 0;
24 /** Represents the bind for the task object pointer. Don't touch it. */
25 private long taskBind = 0;
26 /** Task associated with the comm. Beware, it can be null */
27 protected Task task = null;
29 * Protected constructor, used by Comm factories
35 /** Destroy the C communication object, when the GC reclaims the java part. */
37 protected void finalize() {
40 } catch (Throwable e) {
44 protected native void nativeFinalize();
46 * Returns if the communication is finished or not.
47 * If the communication has finished and there was an error,
50 public native boolean test() throws TransferFailureException, HostFailureException, TimeoutException ;
51 /** Wait infinitely for the completion of the communication (infinite timeout) */
52 public void waitCompletion() throws TransferFailureException, HostFailureException, TimeoutException {
56 * Wait for the completion of the communication.
57 * Throws an exception if there were an error in the communication.
58 * @param timeout Time before giving up (infinite time if negative)
60 public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
63 * Returns the task associated with the communication.
64 * if the communication isn't finished yet, will return null.
66 public Task getTask() {
70 /** Class initializer, to initialize various JNI stuff */
71 public static native void nativeInit();
73 org.simgrid.NativeLib.nativeInit();