From: Martin Quinson Date: Wed, 19 Oct 2011 12:06:11 +0000 (+0200) Subject: split simulation run and simulation cleanup so that users can peek info out of it... X-Git-Tag: v3_9_90~569^2~19^2~171 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/65ec6211dd03e9e6bc31e396393180cc29c27045 split simulation run and simulation cleanup so that users can peek info out of it afterward --- diff --git a/org/simgrid/msg/Msg.java b/org/simgrid/msg/Msg.java index 64c0713ad3..883dbf5295 100644 --- a/org/simgrid/msg/Msg.java +++ b/org/simgrid/msg/Msg.java @@ -76,14 +76,29 @@ public final class Msg { public final static native void init(String[]args); /** - * Run the MSG simulation, and cleanup everything afterward. + * Run the MSG simulation. * - * If you want to chain simulations in the same process, you - * should call again createEnvironment and deployApplication afterward. + * The simulation is not cleaned afterward (see + * {@link #clean()} if you really insist on cleaning the C side), so you can freely + * retrieve the informations that you want from the simulation. In particular, retrieving the status + * of a process or the current date is perfectly ok. * - * @see MSG_run, MSG_clean + * @see MSG_run */ public final static native void run() ; + + /** + * Cleanup the MSG simulation. + * + * This function is only useful if you want to chain the simulations within + * the same environment. But actually, it's not sure at all that cleaning the + * JVM is faster than restarting a new one, so it's probable that using this + * function is not a brilliant idea. Do so at own risk. + * + * @see MSG_clean + */ + public final static native void clean(); + /** * The native implemented method to create the environment of the simulation. diff --git a/src/jmsg.c b/src/jmsg.c index dbe6099cf9..b25f487267 100644 --- a/src/jmsg.c +++ b/src/jmsg.c @@ -837,13 +837,17 @@ JNIEXPORT void JNICALL } XBT_INFO("Clean native world"); - /* cleanup native stuff */ - rv = MSG_OK != MSG_clean(); +} +JNIEXPORT void JNICALL + JNICALL Java_org_simgrid_msg_Msg_clean(JNIEnv * env, jclass cls) +{ + /* cleanup native stuff. Calling it is ... useless since leaking memory at the end of the simulation is a non-issue */ + MSG_error_t rv = MSG_OK != MSG_clean(); jxbt_check_res("MSG_clean()", rv, MSG_OK, bprintf ("unexpected error : MSG_clean() failed .. please report this bug ")); } - + JNIEXPORT jint JNICALL Java_org_simgrid_msg_MsgNative_processKillAll(JNIEnv * env, jclass cls, jint jresetPID) diff --git a/src/jmsg.h b/src/jmsg.h index 8bf5a941f3..bfa02c14e2 100644 --- a/src/jmsg.h +++ b/src/jmsg.h @@ -293,6 +293,8 @@ JNIEXPORT jdouble JNICALL Java_org_simgrid_msg_Msg_getClock(JNIEnv *, jclass); JNIEXPORT void JNICALL JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls); +JNIEXPORT void JNICALL + JNICALL Java_org_simgrid_msg_Msg_clean(JNIEnv * env, jclass cls); JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs);