1 /* Functions related to the java process instances. */
3 /* Copyright (c) 2007-2015. The SimGrid Team.
4 * All rights reserved. */
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. */
10 #define MSG_JPROCESS_H
13 #include <simgrid/msg.h>
14 #include <simgrid/simix.h>
18 /* Shut up some errors in eclipse online compiler. I wish such a pimple wouldn't be needed */
25 /* end of eclipse-mandated pimple */
28 extern jfieldID jprocess_field_Process_bind;
29 extern jfieldID jprocess_field_Process_host;
30 extern jfieldID jprocess_field_Process_killTime;
31 extern jfieldID jprocess_field_Process_id;
32 extern jfieldID jprocess_field_Process_name;
33 extern jfieldID jprocess_field_Process_pid;
34 extern jfieldID jprocess_field_Process_ppid;
36 jobject native_to_java_process(msg_process_t process);
39 * This function returns a global reference to the java process instance specified by the parameter jprocess.
41 * @param jprocess The original java process instance.
42 * @param env The env of the current thread
44 * @return The global reference to the original java process instance.
46 jobject jprocess_new_global_ref(jobject jprocess, JNIEnv * env);
49 * This function delete a global reference to a java process instance.
50 * If the java process is alive the function joins it and stops it before.
52 * @param jprocess The global refernce to delete.
53 * @param env The env of the current thread
55 * @see jprocess_join()
56 * @see jprocess_exit()
58 void jprocess_delete_global_ref(jobject jprocess, JNIEnv * env);
61 * This function waits for a java process to terminate.
63 * @param jprocess The java process to wait for.
64 * @param env The env of the current thread
66 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the method
67 join() of this class is not found the function throws the exception NotSuchMethodException.
69 void jprocess_join(jobject jprocess, JNIEnv * env);
72 * This function associated a native process to a java process instance.
74 * @param jprocess The java process instance.
75 * @param process The native process to bind.
76 * @param env The env of the current thread
78 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field
79 * bind of this class is not found the function throws the exception NotSuchFieldException.
81 void jprocess_bind(jobject jprocess, msg_process_t process, JNIEnv * env);
84 * This function returns a native process from a java process instance.
86 * @param jprocess The java process object from which get the native process.
87 * @param env The env of the current thread
89 * @return The function returns the native process associated to the java process object.
91 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field
92 * bind of this class is not found the function throws the exception NotSuchFieldException.
94 msg_process_t jprocess_to_native_process(jobject jprocess, JNIEnv * env);
97 * This function gets the id of the specified java process.
99 * @param jprocess The java process to get the id.
100 * @param env The env of the current thread
102 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field id
103 * of this class is not found the function throws the exception NotSuchFieldException.
105 * @return The id of the specified java process.
107 jlong jprocess_get_id(jobject jprocess, JNIEnv * env);
110 * This function tests if a java process instance is valid.
111 * A java process object is valid if it is bind to a native process.
113 * @param jprocess The java process to test the validity.
114 * @param env The env of the current thread
116 * @return If the java process is valid the function returns true. Otherwise the function returns false.
118 jboolean jprocess_is_valid(jobject jprocess, JNIEnv * env);
121 * This function gets the name of the specified java process.
123 * @param jprocess The java process to get the name.
124 * @param env The env of the current thread
126 * @exception If the class Process is not found the function throws the ClassNotFoundException. If the field name
127 * of this class is not found the function throws the exception NotSuchFieldException.
129 * @return The name of the specified java process.
131 jstring jprocess_get_name(jobject jprocess, JNIEnv * env);
134 * Class org_simgrid_msg_Process
138 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_nativeInit(JNIEnv *env, jclass cls);
141 * Class org_simgrid_msg_Process
143 * Signature (Lorg/simgrid/msg/Host;)V
145 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_create(JNIEnv * env, jobject jprocess_arg, jobject jhostname);
148 * Class org_simgrid_msg_Process
152 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_killAll (JNIEnv *, jclass, jint);
155 * Class org_simgrid_msg_Process
157 * Signature (I)Lorg/simgrid/msg/Process;
159 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_fromPID (JNIEnv *, jclass, jint);
162 * Class org_simgrid_msg_Process
166 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getProperty(JNIEnv *env, jobject jprocess, jobject jname);
169 * Class org_simgrid_msg_Process
170 * Method currentProcess
171 * Signature ()Lorg/simgrid/msg/Process;
173 JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Process_getCurrentProcess (JNIEnv *, jclass);
176 * Class org_simgrid_msg_Process
178 * Signature (Lorg/simgrid/msg/Process;)V
180 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_suspend(JNIEnv * env, jobject jprocess);
183 * Class org_simgrid_msg_Process
185 * Signature (Lorg/simgrid/msg/Process;)V
187 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_resume (JNIEnv *, jobject);
190 * Class org_simgrid_msg_Process
191 * Method setAutoRestart
192 * Signature (Lorg/simgrid/msg/Process;Z)V
194 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setAutoRestart (JNIEnv *, jobject, jboolean);
197 * Class org_simgrid_msg_Process
199 * Signature (Lorg/simgrid/msg/Process;)V
201 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_restart (JNIEnv *, jobject);
204 * Class org_simgrid_msg_Process
206 * Signature (Lorg/simgrid/msg/Process;)Z
208 JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Process_isSuspended (JNIEnv *, jobject);
211 * Class org_simgrid_msg_Process
215 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_sleep (JNIEnv *, jclass, jlong, jint);
218 * Class org_simgrid_msg_Process
222 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor (JNIEnv *, jobject, jdouble);
225 * Class org_simgrid_msg_Process
227 * Signature (Lorg/simgrid/msg/Process;)V
229 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_kill (JNIEnv *, jobject);
232 * Class org_simgrid_msg_Process
234 * Signature (Lorg/simgrid/msg/Host;)V
236 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_migrate (JNIEnv *, jobject, jobject);
238 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_yield(JNIEnv* env, jclass cls);
240 * Class org_simgrid_msg_Process
244 JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_setKillTime (JNIEnv *, jobject, jdouble);
246 JNIEXPORT jint JNICALL Java_org_simgrid_msg_Process_getCount(JNIEnv * env, jclass cls);
249 #endif /* !MSG_JPROCESS_H */