Logo AND Algorithmique Numérique Distribuée

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