Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Forgot to update migrate signature in Process
[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 <simgrid/simix.h>
15
16 jobject native_to_java_process(m_process_t process);
17
18 /**
19  * This function returns a global reference to the  java process instance 
20  * specified by the parameter jprocess.
21  *
22  * @param jprocess              The original java process instance.
23  * @param env                   The env of the current thread
24  *
25  * @return                              The global reference to the original java process 
26  *                                              instance.
27  */
28 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
29
30 /**
31  * This function delete a global reference to a java process instance.
32  * If the java process is alive the function joins it and stops it before.
33  *
34  * @param                               The global refernce to delete.
35  * @param env                   The env of the current thread
36  *
37  * @see                                 jprocess_join()
38  * @see                                 jprocess_exit()
39  */
40 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
41
42 /**
43  *
44  * This function tests if the specified java process instance is alive. 
45  * A java process object is alive if it has been started and has not yet 
46  * terminated.
47  * 
48  * @param jprocess              The java process to test.
49  * @param env                   The env of the current thread
50  *
51  * @exception                   If the class Process is not found the function throws 
52  *                                              the ClassNotFoundException. If the methos isAlive() of 
53  *                                              this class is not found the function throws the exception 
54  *                                              NotSuchMethodException. 
55  *
56  * @return                              If the java process is alive the function returns
57  *                                              true. Otherwise the function returns false.
58  */
59 jboolean jprocess_is_alive(jobject jprocess, JNIEnv * env);
60
61 /**
62  * This function waits for a java process to terminate.
63  *
64  * @param jprocess              The java process ot wait for.
65  * @param env                   The env of the current thread
66  *
67  * @exception                   If the class Process is not found the function throws 
68  *                                              the ClassNotFoundException. If the methos join() of 
69  *                                              this class is not found the function throws the exception 
70  *                                              NotSuchMethodException. 
71  *
72  */
73 void jprocess_join(jobject jprocess, JNIEnv * env);
74
75 /**
76  * This function starts the specified java process.
77  *
78  * @param jprocess              The java process to start.
79  * @param env                   The env of the current thread
80  *
81  * @exception                   If the class Process is not found the function throws 
82  *                                              the ClassNotFoundException. If the methos start() of 
83  *                                              this class is not found the function throws the exception 
84  *                                              NotSuchMethodException. 
85  */
86 void jprocess_start(jobject jprocess, JNIEnv * env);
87
88 /**
89  * This function forces the java process to stop.
90  *
91  * @param jprocess              The java process to stop.
92  * @param env                   The env of the current thread
93  *
94  * @exception                   If the class Process is not found the function throws 
95  *                                              the ClassNotFoundException. If the methos stop() of 
96  *                                              this class is not found the function throws the exception 
97  *                                              NotSuchMethodException. 
98  */
99 void jprocess_exit(jobject jprocess, JNIEnv * env);
100
101 /**
102  * This function associated a native process to a java process instance.
103  *
104  * @param jprocess              The java process instance.
105  * @param process               The native process to bind.
106  * @param env                   The env of the current thread
107  *
108  * @exception                   If the class Process is not found the function throws 
109  *                                              the ClassNotFoundException. If the field bind of 
110  *                                              this class is not found the function throws the exception 
111  *                                              NotSuchFieldException.  
112  */
113 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
114
115 /**
116  * This function returns a native process from a java process instance.
117  *
118  * @param jprocess              The java process object from which get the native process.
119  * @param env                   The env of the current thread
120  *
121  * @return                              The function returns the native process associated to the
122  *                                              java process object.
123  *
124  * @exception                   If the class Process is not found the function throws 
125  *                                              the ClassNotFoundException. If the field bind of 
126  *                                              this class is not found the function throws the exception 
127  *                                              NotSuchFieldException.  
128  */
129 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
130
131 /**
132  * This function gets the id of the specified java process.
133  *
134  * @param jprocess              The java process to get the id.
135  * @param env                   The env of the current thread
136  *
137  * @exception                   If the class Process is not found the function throws 
138  *                                              the ClassNotFoundException. If the field id of 
139  *                                              this class is not found the function throws the exception 
140  *                                              NotSuchFieldException.  
141  *
142  * @return                              The id of the specified java process.
143  */
144 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
145
146 /**
147  * This function tests if a java process instance is valid.
148  * A java process object is valid if it is bind to a native 
149  * process.
150  *
151  * @param jprocess              The java process to test the validity.
152  * @param env                   The env of the current thread
153  *
154  * @return                              If the java process is valid the function returns true.
155  *                                              Otherwise the function returns false.
156  */
157 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
158
159 /**
160  * This function gets the name of the specified java process.
161  *
162  * @param jprocess              The java process to get the name.
163  * @param env                   The env of the current thread
164  *
165  * @exception                   If the class Process is not found the function throws 
166  *                                              the ClassNotFoundException. If the field name of 
167  *                                              this class is not found the function throws the exception 
168  *                                              NotSuchFieldException.  
169  *
170  * @return                              The name of the specified java process.
171  */
172 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
173
174 /**
175  * This function yields the specified java process.
176  *
177  * @param jprocess              The java process to yield.
178  * @param env                   The env of the current thread.
179  *
180  * @exception                   If the class Process is not found the function throws 
181  *                                              the ClassNotFoundException. If the method switchProcess of 
182  *                                              this class is not found the function throws the exception 
183  *                                              NotSuchMethodException.
184  */
185 void jprocess_yield(jobject jprocess, JNIEnv * env);
186
187 /**
188  * This function locks the mutex of the specified java process.
189  *
190  * @param jprocess              The java process of the mutex to lock.
191  * @param env                   The env of the current thread.
192  *
193  * @exception                   If the class Process is not found the function throws 
194  *                                              the ClassNotFoundException. If the method lockMutex of 
195  *                                              this class is not found the function throws the exception 
196  *                                              NotSuchMethodException.
197  */
198 void jprocess_lock_mutex(jobject jprocess, JNIEnv * env);
199
200 /**
201  * This function unlocks the mutex of the specified java process.
202  *
203  * @param jprocess              The java process of the mutex to unlock.
204  * @param env                   The env of the current thread.
205  *
206  * @exception                   If the class Process is not found the function throws 
207  *                                              the ClassNotFoundException. If the method unlockMutex of 
208  *                                              this class is not found the function throws the exception 
209  *                                              NotSuchMethodException.
210  */
211 void jprocess_unlock_mutex(jobject jprocess, JNIEnv * env);
212
213 /**
214  * This function signals the condition of the mutex of the specified java process.
215  *
216  * @param jprocess              The java process of the condtion to signal.
217  * @param env                   The env of the current thread.
218  *
219  * @exception                   If the class Process is not found the function throws 
220  *                                              the ClassNotFoundException. If the method signalCond of 
221  *                                              this class is not found the function throws the exception 
222  *                                              NotSuchMethodException.
223  */
224 void jprocess_signal_cond(jobject jprocess, JNIEnv * env);
225
226 /**
227  * This function waits the condition of the mutex of the specified java process.
228  *
229  * @param jprocess              The java process of the condtion to wait for.
230  * @param env                   The env of the current thread.
231  *
232  * @exception                   If the class Process is not found the function throws 
233  *                                              the ClassNotFoundException. If the method waitCond of 
234  *                                              this class is not found the function throws the exception 
235  *                                              NotSuchMethodException.
236  */
237 void jprocess_wait_cond(jobject jprocess, JNIEnv * env);
238
239 void jprocess_schedule(smx_context_t context);
240
241 void jprocess_unschedule(smx_context_t context);
242 /*
243  * Class                org_simgrid_msg_Process
244  * Method               nativeInit
245  * Signature    ();
246  */
247 JNIEXPORT void JNICALL
248 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
249
250 /*
251  * Class                org_simgrid_msg_Process
252  * Method               create
253  * Signature    (Lsimgrid/msg/Host;)V
254  */
255 JNIEXPORT void JNICALL
256 Java_org_simgrid_msg_Process_create(JNIEnv * env,
257                                          jobject jprocess, jobject jhost);
258
259 /*
260  * Class                org_simgrid_msg_Process
261  * Method               killAll
262  * Signature    (I)I
263  */
264 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
265     (JNIEnv *, jclass, jint);
266
267 /*
268  * Class                org_simgrid_msg_Process
269  * Method               fromPID
270  * Signature    (I)Lsimgrid/msg/Process;
271  */
272 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
273     (JNIEnv *, jclass, jint);
274
275 /*
276  * Class                org_simgrid_msg_Process
277  * Method               currentProcess
278  * Signature    ()Lsimgrid/msg/Process;
279  */
280 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
281     (JNIEnv *, jclass);
282 /*
283  * Class                org_simgrid_msg_Process
284  * Method               pause
285  * Signature    (Lsimgrid/msg/Process;)V
286  */
287 JNIEXPORT void JNICALL
288 Java_org_simgrid_msg_Process_pause(JNIEnv * env,
289                                           jobject jprocess);
290 /*
291  * Class                org_simgrid_msg_Process
292  * Method               restart
293  * Signature    (Lsimgrid/msg/Process;)V
294  */
295 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
296     (JNIEnv *, jobject);
297 /*
298  * Class                org_simgrid_msg_Process
299  * Method               isSuspended
300  * Signature    (Lsimgrid/msg/Process;)Z
301  */
302 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
303     (JNIEnv *, jobject);
304 /*
305  * Class                org_simgrid_msg_Process
306  * Method               sleep
307  * Signature    (DI)V
308  */
309 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
310     (JNIEnv *, jclass, jlong, jint);
311
312 /*
313  * Class                org_simgrid_msg_Process
314  * Method               waitFor
315  * Signature    (D)V
316  */
317 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
318     (JNIEnv *, jobject, jdouble);
319 /**
320  * Class                org_simgrid_msg_Process
321  * Method               exit
322  * Signature    ()V
323  */
324 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_exit
325     (JNIEnv *, jobject);
326 /*
327  * Class                org_simgrid_msg_Process
328  * Method               kill
329  * Signature    (Lsimgrid/msg/Process;)V
330  */
331 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
332     (JNIEnv *, jclass, jobject);
333
334 /*
335  * Class                org_simgrid_msg_Process
336  * Method               migrate
337  * Signature    (Lsimgrid/msg/Host;)V
338  */
339 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
340     (JNIEnv *, jobject, jobject);
341
342 #endif                          /* !MSG_JPROCESS_H */