src/jmsg_process.h
src/jmsg_task.c
src/jmsg_task.h
+ src/jmsg_synchro.c
+ src/jmsg_synchro.h
src/jmsg_application_handler.c
src/jmsg_application_handler.h
)
org/simgrid/msg/TaskCancelledException.java
org/simgrid/msg/TimeoutException.java
org/simgrid/msg/TransferFailureException.java
+ org/simgrid/msg/Mutex.java
)
set(JAVA_EXAMPLES
SimGrid-java (3.6.1) unstable; urgency=low
+ * Introduce msg.simgrid.Mutex, exporting simgrid mutex to Java.
* Do not embeed our version of semaphores, java 1.5 can be considered
as sufficiently prevalent for us to not dupplicate its features.
* Make Process.kill(process) an instance method, not a static one
--- /dev/null
+package org.simgrid.msg;
+/** A mutex implemented on top of SimGrid synchronization mechanisms.
+ * You can use it exactly the same way that you use the mutexes,
+ * but to handle the interactions between the threads within the simulation.
+ *
+ * Copyright 2012 The SimGrid team. All right 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.
+ *
+ */
+public class Mutex {
+ private long bind; // The C object -- don't touch it
+
+ public Mutex(int capa) {
+ init(capa);
+ }
+ private native void init(int capacity);
+ public native void acquire();
+ public native void release();
+}
--- /dev/null
+/* Functions exporting the simgrid synchronization mechanisms to the Java world */
+
+/* Copyright (c) 2012. 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. */
+
+#include "jmsg_synchro.h"
+#include "jxbt_utilities.h"
+
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj) {
+ xbt_mutex_t mutex = xbt_mutex_init();
+
+ jfieldID id = jxbt_get_sfield(env, "org/simgrid/msg/Mutex", "bind", "J");
+ if (!id) return;
+
+ (*env)->SetLongField(env, obj, id, (jlong) (long) (mutex));
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj) {
+ xbt_mutex_t mutex;
+
+ jfieldID id = jxbt_get_sfield(env, "org/simgrid/msg/Mutex", "bind", "J");
+ if (!id) return;
+
+ mutex = (xbt_mutex_t) (long) (*env)->GetLongField(env, obj, id);
+ xbt_mutex_acquire(mutex);
+}
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject obj) {
+ xbt_mutex_t mutex;
+
+ jfieldID id = jxbt_get_sfield(env, "org/simgrid/msg/Mutex", "bind", "J");
+ if (!id) return;
+
+ mutex = (xbt_mutex_t) (long) (*env)->GetLongField(env, obj, id);
+ xbt_mutex_release(mutex);
+}
--- /dev/null
+/* Functions related to the java process instances. */
+
+/* Copyright (c) 2007, 2009, 2010. 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. */
+
+#ifndef MSG_JSYNCHRO_H
+#define MSG_JSYNCHRO_H
+
+#include <jni.h>
+#include <msg/msg.h>
+#include <simgrid/simix.h>
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj);
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj);
+
+JNIEXPORT void JNICALL
+Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject obj);
+
+
+#endif /* !MSG_JPROCESS_H */