Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix platform file for mutual exclusion example. Fix the associated test
[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  * This function associated a native process to a java process instance.
58  *
59  * @param jprocess              The java process instance.
60  * @param process               The native process to bind.
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 field bind of 
65  *                                              this class is not found the function throws the exception 
66  *                                              NotSuchFieldException.  
67  */
68 void jprocess_bind(jobject jprocess, m_process_t process, JNIEnv * env);
69
70 /**
71  * This function returns a native process from a java process instance.
72  *
73  * @param jprocess              The java process object from which get the native process.
74  * @param env                   The env of the current thread
75  *
76  * @return                              The function returns the native process associated to the
77  *                                              java process object.
78  *
79  * @exception                   If the class Process is not found the function throws 
80  *                                              the ClassNotFoundException. If the field bind of 
81  *                                              this class is not found the function throws the exception 
82  *                                              NotSuchFieldException.  
83  */
84 m_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
85
86 /**
87  * This function gets the id of the specified java process.
88  *
89  * @param jprocess              The java process to get the id.
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 field id of 
94  *                                              this class is not found the function throws the exception 
95  *                                              NotSuchFieldException.  
96  *
97  * @return                              The id of the specified java process.
98  */
99 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
100
101 /**
102  * This function tests if a java process instance is valid.
103  * A java process object is valid if it is bind to a native 
104  * process.
105  *
106  * @param jprocess              The java process to test the validity.
107  * @param env                   The env of the current thread
108  *
109  * @return                              If the java process is valid the function returns true.
110  *                                              Otherwise the function returns false.
111  */
112 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
113
114 /**
115  * This function gets the name of the specified java process.
116  *
117  * @param jprocess              The java process to get the name.
118  * @param env                   The env of the current thread
119  *
120  * @exception                   If the class Process is not found the function throws 
121  *                                              the ClassNotFoundException. If the field name of 
122  *                                              this class is not found the function throws the exception 
123  *                                              NotSuchFieldException.  
124  *
125  * @return                              The name of the specified java process.
126  */
127 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
128
129 /*
130  * Class                org_simgrid_msg_Process
131  * Method               nativeInit
132  * Signature    ();
133  */
134 JNIEXPORT void JNICALL
135 Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
136
137 /*
138  * Class                org_simgrid_msg_Process
139  * Method               create
140  * Signature    (Lsimgrid/msg/Host;)V
141  */
142 JNIEXPORT void JNICALL
143 Java_org_simgrid_msg_Process_create(JNIEnv * env,
144                                          jobject jprocess, jobject jhost);
145
146 /*
147  * Class                org_simgrid_msg_Process
148  * Method               killAll
149  * Signature    (I)I
150  */
151 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll
152     (JNIEnv *, jclass, jint);
153
154 /*
155  * Class                org_simgrid_msg_Process
156  * Method               fromPID
157  * Signature    (I)Lsimgrid/msg/Process;
158  */
159 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID
160     (JNIEnv *, jclass, jint);
161
162 /*
163  * Class                org_simgrid_msg_Process
164  * Method               currentProcess
165  * Signature    ()Lsimgrid/msg/Process;
166  */
167 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_currentProcess
168     (JNIEnv *, jclass);
169 /*
170  * Class                org_simgrid_msg_Process
171  * Method               pause
172  * Signature    (Lsimgrid/msg/Process;)V
173  */
174 JNIEXPORT void JNICALL
175 Java_org_simgrid_msg_Process_pause(JNIEnv * env,
176                                           jobject jprocess);
177 /*
178  * Class                org_simgrid_msg_Process
179  * Method               restart
180  * Signature    (Lsimgrid/msg/Process;)V
181  */
182 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart
183     (JNIEnv *, jobject);
184 /*
185  * Class                org_simgrid_msg_Process
186  * Method               isSuspended
187  * Signature    (Lsimgrid/msg/Process;)Z
188  */
189 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended
190     (JNIEnv *, jobject);
191 /*
192  * Class                org_simgrid_msg_Process
193  * Method               sleep
194  * Signature    (DI)V
195  */
196 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep
197     (JNIEnv *, jclass, jlong, jint);
198
199 /*
200  * Class                org_simgrid_msg_Process
201  * Method               waitFor
202  * Signature    (D)V
203  */
204 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor
205     (JNIEnv *, jobject, jdouble);
206 /*
207  * Class                org_simgrid_msg_Process
208  * Method               kill
209  * Signature    (Lsimgrid/msg/Process;)V
210  */
211 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill
212     (JNIEnv *, jobject);
213
214 /*
215  * Class                org_simgrid_msg_Process
216  * Method               migrate
217  * Signature    (Lsimgrid/msg/Host;)V
218  */
219 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate
220     (JNIEnv *, jobject, jobject);
221 #endif                          /* !MSG_JPROCESS_H */