/* 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. */
-#include <simgrid/s4u/host.hpp>
+#include "simgrid/s4u/Host.hpp"
-#include "jmsg.h"
+#include "jmsg.hpp"
#include "jmsg_host.h"
-#include "jmsg_task.h"
#include "jmsg_process.h"
-#include "jxbt_utilities.h"
+#include "jmsg_task.h"
+#include "jxbt_utilities.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
-SG_BEGIN_DECL()
+extern "C" {
static jmethodID jtask_method_Comm_constructor;
int host_count = static_cast<int>(env->GetArrayLength(jhosts));
jdouble* jcomputeDurations = env->GetDoubleArrayElements(jcomputeDurations_arg, 0);
- msg_host_t* hosts = xbt_new0(msg_host_t, host_count);
- double* computeDurations = xbt_new0(double, host_count);
+ msg_host_t* hosts = new msg_host_t[host_count];
+ double* computeDurations = new double[host_count];
for (int index = 0; index < host_count; index++) {
jobject jhost = env->GetObjectArrayElement(jhosts, index);
hosts[index] = jhost_get_native(env, jhost);
env->ReleaseDoubleArrayElements(jcomputeDurations_arg, jcomputeDurations, 0);
jdouble* jmessageSizes = env->GetDoubleArrayElements(jmessageSizes_arg, 0);
- double* messageSizes = xbt_new0(double, host_count* host_count);
+ double* messageSizes = new double[host_count * host_count];
for (int index = 0; index < host_count * host_count; index++) {
messageSizes[index] = jmessageSizes[index];
}
/* associate the java task object and the native task */
jtask_bind(jtask, task, env);
+
+ delete[] hosts;
+ delete[] computeDurations;
+ delete[] messageSizes;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_cancel(JNIEnv * env, jobject jtask)
{
msg_task_t ptask = jtask_to_native(jtask, env);
- if (!ptask) {
+ if (not ptask) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
msg_error_t rv = MSG_task_cancel(ptask);
- jxbt_check_res("MSG_task_cancel()", rv, MSG_OK, bprintf("unexpected error , please report this bug"));
+ jxbt_check_res("MSG_task_cancel()", rv, MSG_OK, "unexpected error , please report this bug");
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_execute(JNIEnv * env, jobject jtask)
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
JNIEXPORT jstring JNICALL Java_org_simgrid_msg_Task_getName(JNIEnv * env, jobject jtask) {
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
msg_host_t host;
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return nullptr;
}
if (host == nullptr) {
return nullptr;
}
- if (!host->extension(JAVA_HOST_LEVEL)) {
+ if (not host->extension(JAVA_HOST_LEVEL)) {
jxbt_throw_jni(env, "MSG_task_get_source() failed");
return nullptr;
}
{
msg_task_t ptask = jtask_to_native(jtask, env);
- if (!ptask) {
+ if (not ptask) {
jxbt_throw_notbound(env, "task", jtask);
return -1;
}
- return (jdouble) MSG_task_get_flops_amount(ptask);
+ return (jdouble)MSG_task_get_flops_amount(ptask);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setName(JNIEnv *env, jobject jtask, jobject jname) {
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
jdouble jtimeout,jdouble maxrate)
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecv(JNIEnv * env, jclass cls, jstring jmailbox) {
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class)
+ if (not comm_class)
return nullptr;
//pointer to store the task object pointer.
- msg_task_t *task = xbt_new(msg_task_t,1);
- *task = nullptr;
+ msg_task_t* task = new msg_task_t(nullptr);
/* There should be a cache here */
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
- if (!jcomm) {
+ if (not jcomm) {
jxbt_throw_jni(env, "Can't create a Comm object.");
return nullptr;
}
jdouble rate)
{
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class)
+ if (not comm_class)
return nullptr;
// pointer to store the task object pointer.
- msg_task_t* task = xbt_new0(msg_task_t, 1);
+ msg_task_t* task = new msg_task_t(nullptr);
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
- if (!jcomm) {
+ if (not jcomm) {
jxbt_throw_jni(env, "Can't create a Comm object.");
return nullptr;
}
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class) return nullptr;
+ if (not comm_class)
+ return nullptr;
jobject jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
const char* mailbox = env->GetStringUTFChars(jmailbox, 0);
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jmailbox, mailbox);
env->DeleteLocalRef(jcomm);
jxbt_throw_notbound(env, "task", jtask);
const char *mailbox;
jclass comm_class = env->FindClass("org/simgrid/msg/Comm");
- if (!comm_class)
+ if (not comm_class)
return nullptr;
jcomm = env->NewObject(comm_class, jtask_method_Comm_constructor);
task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jmailbox, mailbox);
env->DeleteLocalRef(jcomm);
jxbt_throw_notbound(env, "task", jtask);
{
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
jxbt_throw_notbound(env, "task", jtask);
return;
}
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jalias, alias);
jxbt_throw_notbound(env, "task", jtask);
return;
msg_task_t task = jtask_to_native(jtask, env);
- if (!task) {
+ if (not task) {
env->ReleaseStringUTFChars(jalias, alias);
jxbt_throw_notbound(env, "task", jtask);
return;
return (jint) rv;
}
-
-SG_END_DECL()
+}