Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Using std::remove_if is overkill here.
[simgrid.git] / src / bindings / java / jmsg_vm.cpp
index fc5da71..d1ca0a7 100644 (file)
@@ -65,20 +65,21 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv *env, jobject jvm
   MSG_vm_set_bound(vm, bound);
 }
 
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname,
-                                                      jint jramsize, jint jmig_netspeed, jint jdp_intensity)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jVm, jobject jHost, jstring jname,
+                                                      jint coreAmount, jint jramsize, jint jmig_netspeed,
+                                                      jint jdp_intensity)
 {
-  msg_host_t host = jhost_get_native(env, jhost);
+  msg_host_t host = jhost_get_native(env, jHost);
 
   const char* name = env->GetStringUTFChars(jname, 0);
-  msg_vm_t vm = MSG_vm_create(host, name, static_cast<int>(jramsize), static_cast<int>(jmig_netspeed),
-                              static_cast<int>(jdp_intensity));
+  msg_vm_t vm      = MSG_vm_create(host, name, static_cast<int>(coreAmount), static_cast<int>(jramsize),
+                              static_cast<int>(jmig_netspeed), static_cast<int>(jdp_intensity));
   env->ReleaseStringUTFChars(jname, name);
 
-  jvm_bind(env, jvm, vm);
-  jvm = env->NewWeakGlobalRef(jvm);
+  jvm_bind(env, jVm, vm);
+  jVm = env->NewWeakGlobalRef(jVm);
   // We use the extension level of the host, even if that's somehow disturbing
-  vm->extension_set(JAVA_HOST_LEVEL, (void*)jvm);
+  vm->extension_set(JAVA_HOST_LEVEL, (void*)jVm);
 }
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg)
@@ -135,11 +136,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_shutdown(JNIEnv *env, jobject jvm
   if (vm) {
     MSG_vm_shutdown(vm);
     auto vmList = &simgrid::vm::VirtualMachineImpl::allVms_;
-    vmList->erase(
-        std::remove_if(vmList->begin(), vmList->end(), [vm](simgrid::s4u::VirtualMachine* it) {
-          return vm == it;
-        }),
-        vmList->end());
+    vmList->erase(std::remove(vmList->begin(), vmList->end(), vm), vmList->end());
   }
 }
 
@@ -173,7 +170,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclas
 
   /* get the C string from the java string */
   if (jname == nullptr) {
-    jxbt_throw_null(env, bprintf("No VM can have a null name"));
+    jxbt_throw_null(env, "No VM can have a null name");
     return nullptr;
   }
   const char* name = env->GetStringUTFChars(jname, 0);