Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Load libSG_java instead of SG_java
[simgrid.git] / src / jmsg_process.h
1 /* Functions related to the java process instances.                         */
2
3 /* Copyright (c) 2007, 2009, 2010. The SimGrid Team.
4  * All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7   * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef MSG_JPROCESS_H
10 #define MSG_JPROCESS_H
11
12 #include <jni.h>
13 #include "msg/msg.h"
14 #include "simix/simix.h"
15
16 /**
17  * This function returns a global reference to the  java process instance 
18  * specified by the parameter jprocess.
19  *
20  * @param jprocess              The original java process instance.
21  * @param env                   The env of the current thread
22  *
23  * @return                              The global reference to the original java process 
24  *                                              instance.
25  */
26 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
27
28 /**
29  * This function delete a global reference to a java process instance.
30  * If the java process is alive the function joins it and stops it before.
31  *
32  * @param                               The global refernce to delete.
33  * @param env                   The env of the current thread
34  *
35  * @see                                 jprocess_join()
36  * @see                                 jprocess_exit()
37  */
38 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
39
40 /**
41  *
42  * This function tests if the specified java process instance is alive. 
43  * A java process object is alive if it has been started and has not yet 
44  * terminated.
45  * 
46  * @param jprocess              The java process to test.
47  * @param env                   The env of the current thread
48  *
49  * @exception                   If the class Process is not found the function throws 
50  *                                              the ClassNotFoundException. If the methos isAlive() of 
51  *                                              this class is not found the function throws the exception 
52  *                                              NotSuchMethodException. 
53  *
54  * @return                              If the java process is alive the function returns
55  *                                              true. Otherwise the function returns false.
56  */
57 jboolean jprocess_is_alive(jobject jprocess, JNIEnv * env);
58
59 /**
60  * This function waits for a java process to terminate.
61  *
62  * @param jprocess              The java process ot wait for.
63  * @param env                   The env of the current thread
64  *
65  * @exception                   If the class Process is not found the function throws 
66  *                                              the ClassNotFoundException. If the methos join() of 
67  *                                              this class is not found the function throws the exception 
68  *                                              NotSuchMethodException. 
69  *
70  */
71 void jprocess_join(jobject jprocess, JNIEnv * env);
72
73 /**
74  * This function starts the specified java process.
75  *
76  * @param jprocess              The java process to start.
77  * @param env                   The env of the current thread
78  *
79  * @exception                   If the class Process is not found the function throws 
80  *                                              the ClassNotFoundException. If the methos start() of 
81  *                                              this class is not found the function throws the exception 
82  *                                              NotSuchMethodException. 
83  */
84 void jprocess_start(jobject jprocess, JNIEnv * env);
85
86 /**
87  * This function forces the java process to stop.
88  *
89  * @param jprocess              The java process to stop.
90  * @param env                   The env of the current thread
91  *
92  * @exception                   If the class Process is not found the function throws 
93  *                                              the ClassNotFoundException. If the methos stop() of 
94  *                                              this class is not found the function throws the exception 
95  *                                              NotSuchMethodException. 
96  */
97 void jprocess_exit(jobject jprocess, JNIEnv * env);
98
99 /**
100  * This function associated a native process to a java process instance.
101  *
102  * @param jprocess              The java process instance.
103  * @param process               The native process to bind.
104  * @param env                   The env of the current thread
105  *
106  * @exception                   If the class Process is not found the function throws 
107  *                                              the ClassNotFoundException. If the field bind of 
108  *                                              this class is not found the function throws the exception 
109  *                                              NotSuchFieldException.  
110  */
111 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
112
113 /**
114  * This function returns a native process from a java process instance.
115  *
116  * @param jprocess              The java process object from which get the native process.
117  * @param env                   The env of the current thread
118  *
119  * @return                              The function returns the native process associated to the
120  *                                              java process object.
121  *
122  * @exception                   If the class Process is not found the function throws 
123  *                                              the ClassNotFoundException. If the field bind of 
124  *                                              this class is not found the function throws the exception 
125  *                                              NotSuchFieldException.  
126  */
127 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
128
129 /**
130  * This function gets the id of the specified java process.
131  *
132  * @param jprocess              The java process to get the id.
133  * @param env                   The env of the current thread
134  *
135  * @exception                   If the class Process is not found the function throws 
136  *                                              the ClassNotFoundException. If the field id of 
137  *                                              this class is not found the function throws the exception 
138  *                                              NotSuchFieldException.  
139  *
140  * @return                              The id of the specified java process.
141  */
142 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
143
144 /**
145  * This function tests if a java process instance is valid.
146  * A java process object is valid if it is bind to a native 
147  * process.
148  *
149  * @param jprocess              The java process to test the validity.
150  * @param env                   The env of the current thread
151  *
152  * @return                              If the java process is valid the function returns true.
153  *                                              Otherwise the function returns false.
154  */
155 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
156
157 /**
158  * This function gets the name of the specified java process.
159  *
160  * @param jprocess              The java process to get the name.
161  * @param env                   The env of the current thread
162  *
163  * @exception                   If the class Process is not found the function throws 
164  *                                              the ClassNotFoundException. If the field name of 
165  *                                              this class is not found the function throws the exception 
166  *                                              NotSuchFieldException.  
167  *
168  * @return                              The name of the specified java process.
169  */
170 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
171
172 /**
173  * This function yields the specified java process.
174  *
175  * @param jprocess              The java process to yield.
176  * @param env                   The env of the current thread.
177  *
178  * @exception                   If the class Process is not found the function throws 
179  *                                              the ClassNotFoundException. If the method switchProcess of 
180  *                                              this class is not found the function throws the exception 
181  *                                              NotSuchMethodException.
182  */
183 void jprocess_yield(jobject jprocess, JNIEnv * env);
184
185 /**
186  * This function locks the mutex of the specified java process.
187  *
188  * @param jprocess              The java process of the mutex to lock.
189  * @param env                   The env of the current thread.
190  *
191  * @exception                   If the class Process is not found the function throws 
192  *                                              the ClassNotFoundException. If the method lockMutex of 
193  *                                              this class is not found the function throws the exception 
194  *                                              NotSuchMethodException.
195  */
196 void jprocess_lock_mutex(jobject jprocess, JNIEnv * env);
197
198 /**
199  * This function unlocks the mutex of the specified java process.
200  *
201  * @param jprocess              The java process of the mutex to unlock.
202  * @param env                   The env of the current thread.
203  *
204  * @exception                   If the class Process is not found the function throws 
205  *                                              the ClassNotFoundException. If the method unlockMutex of 
206  *                                              this class is not found the function throws the exception 
207  *                                              NotSuchMethodException.
208  */
209 void jprocess_unlock_mutex(jobject jprocess, JNIEnv * env);
210
211 /**
212  * This function signals the condition of the mutex of the specified java process.
213  *
214  * @param jprocess              The java process of the condtion to signal.
215  * @param env                   The env of the current thread.
216  *
217  * @exception                   If the class Process is not found the function throws 
218  *                                              the ClassNotFoundException. If the method signalCond of 
219  *                                              this class is not found the function throws the exception 
220  *                                              NotSuchMethodException.
221  */
222 void jprocess_signal_cond(jobject jprocess, JNIEnv * env);
223
224 /**
225  * This function waits the condition of the mutex of the specified java process.
226  *
227  * @param jprocess              The java process of the condtion to wait for.
228  * @param env                   The env of the current thread.
229  *
230  * @exception                   If the class Process is not found the function throws 
231  *                                              the ClassNotFoundException. If the method waitCond of 
232  *                                              this class is not found the function throws the exception 
233  *                                              NotSuchMethodException.
234  */
235 void jprocess_wait_cond(jobject jprocess, JNIEnv * env);
236
237 void jprocess_schedule(smx_context_t context);
238
239 void jprocess_unschedule(smx_context_t context);
240
241
242 #endif                          /* !MSG_JPROCESS_H */