Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merging changes done by Steven, Samuel and Luka, regarding simulation of StarPU-MPI
[simgrid.git] / src / bindings / java / jmsg_process.h
1 /* Functions related to the java process instances.                         */
2
3 /* Copyright (c) 2007-2015. 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 <simgrid/msg.h>
14 #include <simgrid/simix.h>
15
16 SG_BEGIN_DECL();
17
18 //Cached java fields
19 extern jfieldID jprocess_field_Process_bind;
20 extern jfieldID jprocess_field_Process_host;
21 extern jfieldID jprocess_field_Process_killTime;
22 extern jfieldID jprocess_field_Process_id;
23 extern jfieldID jprocess_field_Process_name;
24 extern jfieldID jprocess_field_Process_pid;
25 extern jfieldID jprocess_field_Process_ppid;
26
27 JNIEXPORT void JNICALL
28 Java_org_simgrid_msg_Process_exit(JNIEnv *env, jobject);
29
30
31 jobject native_to_java_process(msg_process_t process);
32
33 /**
34  * This function returns a global reference to the  java process instance 
35  * specified by the parameter jprocess.
36  *
37  * @param jprocess              The original java process instance.
38  * @param env                   The env of the current thread
39  *
40  * @return                              The global reference to the original java process 
41  *                                              instance.
42  */
43 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
44
45 /**
46  * This function delete a global reference to a java process instance.
47  * If the java process is alive the function joins it and stops it before.
48  *
49  * @param                               The global refernce to delete.
50  * @param env                   The env of the current thread
51  *
52  * @see                                 jprocess_join()
53  * @see                                 jprocess_exit()
54  */
55 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
56
57
58 /**
59  * This function waits for a java process to terminate.
60  *
61  * @param jprocess              The java process ot wait for.
62  * @param env                   The env of the current thread
63  *
64  * @exception                   If the class Process is not found the function throws 
65  *                                              the ClassNotFoundException. If the methos join() of 
66  *                                              this class is not found the function throws the exception 
67  *                                              NotSuchMethodException. 
68  *
69  */
70 void jprocess_join(jobject jprocess, JNIEnv * env);
71 /**
72  * This function associated a native process to a java process instance.
73  *
74  * @param jprocess              The java process instance.
75  * @param process               The native process to bind.
76  * @param env                   The env of the current thread
77  *
78  * @exception                   If the class Process is not found the function throws 
79  *                                              the ClassNotFoundException. If the field bind of 
80  *                                              this class is not found the function throws the exception 
81  *                                              NotSuchFieldException.  
82  */
83 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
84
85 /**
86  * This function returns a native process from a java process instance.
87  *
88  * @param jprocess              The java process object from which get the native process.
89  * @param env                   The env of the current thread
90  *
91  * @return                              The function returns the native process associated to the
92  *                                              java process object.
93  *
94  * @exception                   If the class Process is not found the function throws 
95  *                                              the ClassNotFoundException. If the field bind of 
96  *                                              this class is not found the function throws the exception 
97  *                                              NotSuchFieldException.  
98  */
99 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
100
101 /**
102  * This function gets the id of the specified java process.
103  *
104  * @param jprocess              The java process to get the id.
105  * @param env                   The env of the current thread
106  *
107  * @exception                   If the class Process is not found the function throws 
108  *                                              the ClassNotFoundException. If the field id of 
109  *                                              this class is not found the function throws the exception 
110  *                                              NotSuchFieldException.  
111  *
112  * @return                              The id of the specified java process.
113  */
114 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
115
116 /**
117  * This function tests if a java process instance is valid.
118  * A java process object is valid if it is bind to a native 
119  * process.
120  *
121  * @param jprocess              The java process to test the validity.
122  * @param env                   The env of the current thread
123  *
124  * @return                              If the java process is valid the function returns true.
125  *                                              Otherwise the function returns false.
126  */
127 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
128
129 /**
130  * This function gets the name of the specified java process.
131  *
132  * @param jprocess              The java process to get the name.
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 name of 
137  *                                              this class is not found the function throws the exception 
138  *                                              NotSuchFieldException.  
139  *
140  * @return                              The name of the specified java process.
141  */
142 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
143
144 /*
145  * Class                org_simgrid_msg_Process
146  * Method               nativeInit
147  * Signature    ();
148  */
149 JNIEXPORT void JNICALL
150 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
151
152 /*
153  * Class                org_simgrid_msg_Process
154  * Method               create
155  * Signature    (Lorg/simgrid/msg/Host;)V
156  */
157 JNIEXPORT void JNICALL
158 Java_org_simgrid_msg_Process_create(JNIEnv * env,
159                                     jobject jprocess_arg,
160                                     jobject jhostname);
161
162 /*
163  * Class                org_simgrid_msg_Process
164  * Method               killAll
165  * Signature    (I)I
166  */
167 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
168     (JNIEnv *, jclass, jint);
169
170 /*
171  * Class                org_simgrid_msg_Process
172  * Method               fromPID
173  * Signature    (I)Lorg/simgrid/msg/Process;
174  */
175 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
176     (JNIEnv *, jclass, jint);
177 /*
178  * Class        org_simgrid_msg_Process
179  * Method       getProperty
180  * Signature    (D)V
181  */
182 JNIEXPORT jobject JNICALL
183 Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
184 /*
185  * Class                org_simgrid_msg_Process
186  * Method               currentProcess
187  * Signature    ()Lorg/simgrid/msg/Process;
188  */
189 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess
190     (JNIEnv *, jclass);
191 /*
192  * Class                org_simgrid_msg_Process
193  * Method               suspend
194  * Signature    (Lorg/simgrid/msg/Process;)V
195  */
196 JNIEXPORT void JNICALL
197 Java_org_simgrid_msg_Process_suspend(JNIEnv * env,
198                                           jobject jprocess);
199 /*
200  * Class                org_simgrid_msg_Process
201  * Method               resume
202  * Signature    (Lorg/simgrid/msg/Process;)V
203  */
204 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume
205     (JNIEnv *, jobject);
206 /*
207  * Class        org_simgrid_msg_Process
208  * Method       setAutoRestart
209  * Signature    (Lorg/simgrid/msg/Process;Z)V
210  */
211 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart
212     (JNIEnv *, jobject, jboolean);
213 /*
214  * Class        org_simgrid_msg_Process
215  * Method       restart
216  * Signature    (Lorg/simgrid/msg/Process;)V
217  */
218 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
219     (JNIEnv *, jobject);
220
221 /*
222  * Class                org_simgrid_msg_Process
223  * Method               isSuspended
224  * Signature    (Lorg/simgrid/msg/Process;)Z
225  */
226 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
227     (JNIEnv *, jobject);
228 /*
229  * Class                org_simgrid_msg_Process
230  * Method               sleep
231  * Signature    (DI)V
232  */
233 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
234     (JNIEnv *, jclass, jlong, jint);
235
236 /*
237  * Class                org_simgrid_msg_Process
238  * Method               waitFor
239  * Signature    (D)V
240  */
241 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
242     (JNIEnv *, jobject, jdouble);
243 /*
244  * Class                org_simgrid_msg_Process
245  * Method               kill
246  * Signature    (Lorg/simgrid/msg/Process;)V
247  */
248 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
249     (JNIEnv *, jobject);
250
251 /*
252  * Class                org_simgrid_msg_Process
253  * Method               migrate
254  * Signature    (Lorg/simgrid/msg/Host;)V
255  */
256 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
257     (JNIEnv *, jobject, jobject);
258 /*
259  * Class                org_simgrid_msg_Process
260  * Method               setKillTime
261  * Signature    (D)V
262  */
263 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime
264     (JNIEnv *, jobject, jdouble);
265
266 JNIEXPORT jint JNICALL
267 Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
268
269 SG_END_DECL();
270
271 #endif                          /* !MSG_JPROCESS_H */