Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Deprecate Msg.clean()
[simgrid.git] / src / jmsg.c
index 3e6fd62..97ba952 100644 (file)
@@ -1,6 +1,6 @@
 /* Java Wrappers to the MSG API.                                            */
 
-/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2007-2012. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@ JNIEnv *get_current_thread_env(void)
   return env;
 }
 
-void jmsg_throw_status(JNIEnv *env, MSG_error_t status) {
+void jmsg_throw_status(JNIEnv *env, msg_error_t status) {
   switch (status) {
     case MSG_TIMEOUT:
         jxbt_throw_time_out_failure(env,NULL);
@@ -89,11 +89,11 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
   (*env)->GetJavaVM(env, &__java_vm);
 
   if ((*env)->FindClass(env, "java/dyn/Coroutine")) {
-       XBT_VERB("Using Coroutines");
+       XBT_INFO("Using Coroutines. Your simulation is on steroid.");
        smx_factory_initializer_to_use = SIMIX_ctx_cojava_factory_init;
   }
   else {
-       XBT_VERB("Using java threads");
+       XBT_INFO("Using regular java threads. Coroutines could speed your simulation up.");
        smx_factory_initializer_to_use = SIMIX_ctx_java_factory_init;
   }
   jthrowable exc = (*env)->ExceptionOccurred(env);
@@ -129,7 +129,7 @@ Java_org_simgrid_msg_Msg_init(JNIEnv * env, jclass cls, jobjectArray jargs)
 JNIEXPORT void JNICALL
     JNICALL Java_org_simgrid_msg_Msg_run(JNIEnv * env, jclass cls)
 {
-  MSG_error_t rv;
+  msg_error_t rv;
   int index;
   xbt_dynar_t hosts;
   jobject jhost;
@@ -148,7 +148,7 @@ JNIEXPORT void JNICALL
   /* Cleanup java hosts */
   hosts = MSG_hosts_as_dynar();
   for (index = 0; index < xbt_dynar_length(hosts) - 1; index++) {
-    jhost = (jobject) MSG_host_get_data(xbt_dynar_get_as(hosts,index,m_host_t));
+    jhost = (jobject) MSG_host_get_data(xbt_dynar_get_as(hosts,index,msg_host_t));
     if (jhost)
       jhost_unref(env, jhost);
 
@@ -156,15 +156,6 @@ JNIEXPORT void JNICALL
   xbt_dynar_free(&hosts);
   XBT_INFO("Clean native world");
 }
-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 void JNICALL
 Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls,
@@ -186,13 +177,40 @@ Java_org_simgrid_msg_Msg_debug(JNIEnv * env, jclass cls, jstring js)
   (*env)->ReleaseStringUTFChars(env, js, s);
 }
 JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Msg_verb(JNIEnv * env, jclass cls, jstring js)
+{
+  const char *s = (*env)->GetStringUTFChars(env, js, 0);
+  XBT_VERB("%s", s);
+  (*env)->ReleaseStringUTFChars(env, js, s);
+}
+JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_info(JNIEnv * env, jclass cls, jstring js)
 {
   const char *s = (*env)->GetStringUTFChars(env, js, 0);
   XBT_INFO("%s", s);
   (*env)->ReleaseStringUTFChars(env, js, s);
 }
-
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Msg_warn(JNIEnv * env, jclass cls, jstring js)
+{
+  const char *s = (*env)->GetStringUTFChars(env, js, 0);
+  XBT_WARN("%s", s);
+  (*env)->ReleaseStringUTFChars(env, js, s);
+}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Msg_error(JNIEnv * env, jclass cls, jstring js)
+{
+  const char *s = (*env)->GetStringUTFChars(env, js, 0);
+  XBT_ERROR("%s", s);
+  (*env)->ReleaseStringUTFChars(env, js, s);
+}
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Msg_critical(JNIEnv * env, jclass cls, jstring js)
+{
+  const char *s = (*env)->GetStringUTFChars(env, js, 0);
+  XBT_CRITICAL("%s", s);
+  (*env)->ReleaseStringUTFChars(env, js, s);
+}
 JNIEXPORT void JNICALL
 Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls,
                                        jstring jdeploymentFile)
@@ -237,7 +255,7 @@ static int create_jprocess(int argc, char *argv[]) {
   xbt_assert((jprocess != NULL), "Process allocation failed.");
   jprocess = (*env)->NewGlobalRef(env, jprocess);
   //bind the process to the context
-  m_process_t process = MSG_process_self();
+  msg_process_t process = MSG_process_self();
   smx_ctx_java_t context = (smx_ctx_java_t)MSG_process_get_smx_ctx(process);
   context->jprocess = jprocess;
 /* sets the PID and the PPID of the process */