Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix the handling of errors in Task.send
[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         boolean receiving;
19         /**
20          * Represents the bind between the java comm and the
21          * native C comm. You must never access it, since it is 
22          * automatically set.
23          */
24         public long bind = 0;
25         /**
26          * Represents the bind for the task object pointer. Don't touch it.
27          */
28         public long taskBind = 0;
29         /**
30          * Task associated with the comm. Beware, it can be null 
31          */
32         protected Task task = null;
33         /**
34          * Protected constructor, used by Comm factories
35          * in Task.
36          */
37         protected Comm() {
38
39         }
40         /**
41          * Finalize the communication object, destroying it.
42          */
43         protected void finalize() throws Throwable {
44                 destroy();
45         }
46         /**
47          * Unbind the communication object
48          */
49         public native void destroy() throws NativeException;
50         /**
51          * Returns if the communication is finished or not.
52          * If the communication has finished and there was an error,
53          * raise an exception.
54          */
55         public native boolean test() throws TransferFailureException, HostFailureException, TimeoutException ;
56         /**
57          * Wait for the completion of the communication.
58          * Throws an exception if there were an error in the communication.
59          */
60         public native void waitCompletion(double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
61         /**
62          * Returns the task associated with the communication.
63          * if the communication isn't finished yet, will return null.
64          */
65         public Task getTask() {
66                 return task;
67         }
68
69         /**
70          * Class initializer, to initialize various JNI stuff
71          */
72         public static native void nativeInit();
73         static {
74                 nativeInit();
75         }       
76 }