Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into adrien
[simgrid.git] / src / bindings / java / JavaContext.cpp
index 99642af..29cf71f 100644 (file)
@@ -1,6 +1,6 @@
 /* Context switching within the JVM.                                        */
 
-/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,15 +29,14 @@ ContextFactory* java_factory()
 
 JavaContextFactory::JavaContextFactory() : ContextFactory()
 {
-  xbt_binary_name = xbt_strdup("java"); // Used by the backtrace displayer
+  xbt_assert(xbt::binary_name == "java");
 }
 
 JavaContextFactory::~JavaContextFactory()=default;
 
-JavaContext* JavaContextFactory::create_context(std::function<void()> code, void_pfn_smxprocess_t cleanup_fun,
-                                                smx_actor_t actor)
+Context* JavaContextFactory::create_context(std::function<void()>&& code, actor::ActorImpl* actor)
 {
-  return this->new_context<JavaContext>(std::move(code), cleanup_fun, actor);
+  return this->new_context<JavaContext>(std::move(code), actor);
 }
 
 void JavaContextFactory::run_all()
@@ -45,8 +44,8 @@ void JavaContextFactory::run_all()
   SerialThreadContext::run_all();
 }
 
-JavaContext::JavaContext(std::function<void()> code, void_pfn_smxprocess_t cleanup_func, smx_actor_t process)
-    : SerialThreadContext(std::move(code), cleanup_func, process, false /* not maestro */)
+JavaContext::JavaContext(std::function<void()>&& code, smx_actor_t actor)
+    : SerialThreadContext(std::move(code), actor, false /* not maestro */)
 {
   /* ThreadContext already does all we need */
 }
@@ -66,7 +65,7 @@ void JavaContext::stop_hook()
 {
     JNIEnv* env = this->jenv_;
     env->DeleteGlobalRef(this->jprocess_);
-    XBT_ATTRIB_UNUSED jint error = __java_vm->DetachCurrentThread();
+    jint error = __java_vm->DetachCurrentThread();
     if (error != JNI_OK) {
       /* This is probably a Java thread, ie an actor not created from the XML (and thus from the C++),
        * but from Java with something like new Process().start().