return (jdouble) MSG_get_clock();
}
+/*Hack: let msg load directly the right factory */
+typedef void (*SIMIX_ctx_factory_initializer_t)(smx_context_factory_t *);
+extern SIMIX_ctx_factory_initializer_t factory_initializer_to_use;
JNIEXPORT void JNICALL
Java_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
jstring jval;
const char *tmp;
+ factory_initializer_to_use = SIMIX_ctx_java_factory_init;
+
if (jargs)
argc = (int) (*env)->GetArrayLength(env, jargs);
}
MSG_global_init(&argc, argv);
- SIMIX_context_select_factory("java");
for (index = 0; index < argc; index++)
free(argv[index]);
return jtable;
}
-
-JNIEXPORT void JNICALL
-Java_simgrid_msg_MsgNative_selectContextFactory(JNIEnv * env, jclass class,
- jstring jname)
-{
- char *errmsg = NULL;
- xbt_ex_t e;
-
- /* get the C string from the java string */
- const char *name = (*env)->GetStringUTFChars(env, jname, 0);
-
- TRY {
- SIMIX_context_select_factory(name);
- } CATCH(e) {
- errmsg = xbt_strdup(e.msg);
- xbt_ex_free(e);
- }
-
- (*env)->ReleaseStringUTFChars(env, jname, name);
-
- if (errmsg) {
- char *thrown =
- bprintf("xbt_select_context_factory() failed: %s", errmsg);
- free(errmsg);
- jxbt_throw_jni(env, thrown);
- }
-}
-
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_taskSend(JNIEnv * env, jclass cls,
jstring jalias, jobject jtask,
Java_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls,
jstring jplatformFile);
-JNIEXPORT void JNICALL
-Java_simgrid_msg_MsgNative_selectContextFactory(JNIEnv *, jclass, jstring);
-
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_taskSendBounded(JNIEnv *, jclass, jstring,
jobject, jdouble);
*/
final class MsgNative {
- final static native
- void selectContextFactory(String name) throws NativeException;
-
/******************************************************************
* The natively implemented methods connected to the MSG Process *
******************************************************************/
*/
final static native void taskSendBounded(String alias, Task task, double maxrate) throws TransferFailureException,HostFailureException,TimeoutException;
-}
\ No newline at end of file
+}
/* init the desired factory */
smx_context_factory_t * factory = &simix_global->context_factory;
- if (!strcmp(name, "java"))
-#ifdef HAVE_JAVA
- SIMIX_ctx_java_factory_init(factory);
-#else
- THROW0(not_found_error, 0,
- "Factory 'Java' does not exist: Java support was not compiled in the SimGrid library");
-#endif /* HAVE_JAVA */
-
- else if (!strcmp(name, "thread"))
+ if (!strcmp(name, "thread"))
#ifdef CONTEXT_THREADS
SIMIX_ctx_thread_factory_init(factory);
#else