Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change the way the threads are stopped, not killing the JVM at the end of the simulation.
[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 waits for a java process to terminate.
45  *
46  * @param jprocess              The java process ot wait for.
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 join() of 
51  *                                              this class is not found the function throws the exception 
52  *                                              NotSuchMethodException. 
53  *
54  */
55 void jprocess_join(jobject jprocess, JNIEnv * env);
56
57 /**
58  * This function starts the specified java process.
59  *
60  * @param jprocess              The java process to start.
61  * @param env                   The env of the current thread
62  *
63  * @exception                   If the class Process is not found the function throws 
64  *                                              the ClassNotFoundException. If the methos start() of 
65  *                                              this class is not found the function throws the exception 
66  *                                              NotSuchMethodException. 
67  */
68 void jprocess_start(jobject jprocess, JNIEnv * env);
69
70 /**
71  * This function forces the java process to stop.
72  *
73  * @param jprocess              The java process to stop.
74  * @param env                   The env of the current thread
75  *
76  * @exception                   If the class Process is not found the function throws
77  *                                              the ClassNotFoundException. If the methos stop() of
78  *                                              this class is not found the function throws the exception
79  *                                              NotSuchMethodException.
80  */
81 void jprocess_exit(jobject jprocess, JNIEnv * env);
82
83 /**
84  * This function associated a native process to a java process instance.
85  *
86  * @param jprocess              The java process instance.
87  * @param process               The native process to bind.
88  * @param env                   The env of the current thread
89  *
90  * @exception                   If the class Process is not found the function throws 
91  *                                              the ClassNotFoundException. If the field bind of 
92  *                                              this class is not found the function throws the exception 
93  *                                              NotSuchFieldException.  
94  */
95 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
96
97 /**
98  * This function returns a native process from a java process instance.
99  *
100  * @param jprocess              The java process object from which get the native process.
101  * @param env                   The env of the current thread
102  *
103  * @return                              The function returns the native process associated to the
104  *                                              java process object.
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 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
112
113 /**
114  * This function gets the id of the specified java process.
115  *
116  * @param jprocess              The java process to get the id.
117  * @param env                   The env of the current thread
118  *
119  * @exception                   If the class Process is not found the function throws 
120  *                                              the ClassNotFoundException. If the field id of 
121  *                                              this class is not found the function throws the exception 
122  *                                              NotSuchFieldException.  
123  *
124  * @return                              The id of the specified java process.
125  */
126 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
127
128 /**
129  * This function tests if a java process instance is valid.
130  * A java process object is valid if it is bind to a native 
131  * process.
132  *
133  * @param jprocess              The java process to test the validity.
134  * @param env                   The env of the current thread
135  *
136  * @return                              If the java process is valid the function returns true.
137  *                                              Otherwise the function returns false.
138  */
139 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
140
141 /**
142  * This function gets the name of the specified java process.
143  *
144  * @param jprocess              The java process to get the name.
145  * @param env                   The env of the current thread
146  *
147  * @exception                   If the class Process is not found the function throws 
148  *                                              the ClassNotFoundException. If the field name of 
149  *                                              this class is not found the function throws the exception 
150  *                                              NotSuchFieldException.  
151  *
152  * @return                              The name of the specified java process.
153  */
154 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
155
156 /*
157  * Class                org_simgrid_msg_Process
158  * Method               nativeInit
159  * Signature    ();
160  */
161 JNIEXPORT void JNICALL
162 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
163
164 /*
165  * Class                org_simgrid_msg_Process
166  * Method               create
167  * Signature    (Lsimgrid/msg/Host;)V
168  */
169 JNIEXPORT void JNICALL
170 Java_org_simgrid_msg_Process_create(JNIEnv * env,
171                                          jobject jprocess, jobject jhost);
172
173 /*
174  * Class                org_simgrid_msg_Process
175  * Method               killAll
176  * Signature    (I)I
177  */
178 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
179     (JNIEnv *, jclass, jint);
180
181 /*
182  * Class                org_simgrid_msg_Process
183  * Method               fromPID
184  * Signature    (I)Lsimgrid/msg/Process;
185  */
186 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
187     (JNIEnv *, jclass, jint);
188
189 /*
190  * Class                org_simgrid_msg_Process
191  * Method               currentProcess
192  * Signature    ()Lsimgrid/msg/Process;
193  */
194 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
195     (JNIEnv *, jclass);
196 /*
197  * Class                org_simgrid_msg_Process
198  * Method               pause
199  * Signature    (Lsimgrid/msg/Process;)V
200  */
201 JNIEXPORT void JNICALL
202 Java_org_simgrid_msg_Process_pause(JNIEnv * env,
203                                           jobject jprocess);
204 /*
205  * Class                org_simgrid_msg_Process
206  * Method               restart
207  * Signature    (Lsimgrid/msg/Process;)V
208  */
209 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
210     (JNIEnv *, jobject);
211 /*
212  * Class                org_simgrid_msg_Process
213  * Method               isSuspended
214  * Signature    (Lsimgrid/msg/Process;)Z
215  */
216 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
217     (JNIEnv *, jobject);
218 /*
219  * Class                org_simgrid_msg_Process
220  * Method               sleep
221  * Signature    (DI)V
222  */
223 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
224     (JNIEnv *, jclass, jlong, jint);
225
226 /*
227  * Class                org_simgrid_msg_Process
228  * Method               waitFor
229  * Signature    (D)V
230  */
231 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
232     (JNIEnv *, jobject, jdouble);
233 /*
234  * Class                org_simgrid_msg_Process
235  * Method               kill
236  * Signature    (Lsimgrid/msg/Process;)V
237  */
238 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
239     (JNIEnv *, jclass, jobject);
240
241 /*
242  * Class                org_simgrid_msg_Process
243  * Method               migrate
244  * Signature    (Lsimgrid/msg/Host;)V
245  */
246 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
247     (JNIEnv *, jobject, jobject);
248 #endif                          /* !MSG_JPROCESS_H */