Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
423371db1a09e024d31c4f1ae747b672b621456a
[simgrid.git] / org / simgrid / msg / Comm.java
1 package org.simgrid.msg;
2 /**
3 * Copyright 2012 The SimGrid team. All right reserved. 
4 *
5 * This program is free software; you can redistribute 
6 * it and/or modify it under the terms of the license 
7 * (GNU LGPL) which comes with this package.
8 *
9 */
10 /**
11  * Communication action, representing an ongoing communication
12  * between processes.
13  */
14 public class Comm {
15         /**
16          * Indicates if the communication is a receiving communication
17          */
18         protected boolean receiving;
19         /**
20          * Indicates if the communication is finished
21          */
22         protected boolean finished = false;
23         /**
24          * Represents the bind between the java comm and the
25          * native C comm. You must never access it, since it is 
26          * automatically set.
27          */
28         public long bind = 0;
29         /**
30          * Represents the bind for the task object pointer. Don't touch it.
31          */
32         public long taskBind = 0;
33         /**
34          * Task associated with the comm. Beware, it can be null 
35          */
36         protected Task task = null;
37         /**
38          * Protected constructor, used by Comm factories
39          * in Task.
40          */
41         protected Comm() {
42
43         }
44         /**
45          * Finalize the communication object, destroying it.
46          */
47         protected void finalize() throws Throwable {
48                 destroy();
49         }
50         /**
51          * Unbind the communication object
52          */
53         protected native void destroy() throws NativeException;
54         /**
55          * Returns if the communication is finished or not.
56          * If the communication has finished and there was an error,
57          * raise an exception.
58          */
59         public native boolean test() throws TransferFailureException, HostFailureException, TimeoutException ;
60         /**
61          * Wait for the completion of the communication.
62          * Throws an exception if there were an error in the communication.
63          */
64         public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
65         /**
66          * Returns the task associated with the communication.
67          * if the communication isn't finished yet, will return null.
68          */
69         public Task getTask() {
70                 return task;
71         }
72
73         /**
74          * Class initializer, to initialize various JNI stuff
75          */
76         public static native void nativeInit();
77         static {
78                 nativeInit();
79         }       
80 }