A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update copyright lines for 2022.
[simgrid.git]
/
src
/
bindings
/
java
/
jmsg_synchro.cpp
diff --git
a/src/bindings/java/jmsg_synchro.cpp
b/src/bindings/java/jmsg_synchro.cpp
index
b6d3f6d
..
92ba1cc
100644
(file)
--- a/
src/bindings/java/jmsg_synchro.cpp
+++ b/
src/bindings/java/jmsg_synchro.cpp
@@
-1,6
+1,6
@@
/* Java bindings of the Synchronization API. */
/* Java bindings of the Synchronization API. */
-/* Copyright (c) 2012-20
19
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-20
22
. 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. */
/* 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. */
@@
-9,7
+9,8
@@
#include "jmsg.hpp"
#include "jxbt_utilities.hpp"
#include "simgrid/Exception.hpp"
#include "jmsg.hpp"
#include "jxbt_utilities.hpp"
#include "simgrid/Exception.hpp"
-#include "xbt/synchro.h"
+#include "simgrid/mutex.h"
+#include "simgrid/semaphore.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
@@
-21,30
+22,26
@@
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeInit(JNIEnv *env, jclass
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj) {
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_init(JNIEnv * env, jobject obj) {
-
xbt_mutex_t mutex = xbt
_mutex_init();
+
sg_mutex_t mutex = sg
_mutex_init();
env->SetLongField(obj, jsynchro_field_Mutex_bind, (jlong)(uintptr_t)(mutex));
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj) {
env->SetLongField(obj, jsynchro_field_Mutex_bind, (jlong)(uintptr_t)(mutex));
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_acquire(JNIEnv * env, jobject obj) {
- xbt_mutex_t mutex = (xbt_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
- try {
- xbt_mutex_acquire(mutex);
- } catch (xbt_ex const& e) {
- XBT_DEBUG("Caught an exception: %s", e.what());
- }
+ auto mutex = (sg_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
+ sg_mutex_lock(mutex);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject obj) {
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_release(JNIEnv * env, jobject obj) {
-
xbt
_mutex_t mutex;
+
sg
_mutex_t mutex;
- mutex = (
xbt
_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
-
xbt_mutex_release
(mutex);
+ mutex = (
sg
_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
+
sg_mutex_unlock
(mutex);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) {
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Mutex_nativeFinalize(JNIEnv * env, jobject obj) {
-
xbt_mutex_t mutex = (xbt
_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
-
xbt
_mutex_destroy(mutex);
+
const_sg_mutex_t mutex = (sg
_mutex_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Mutex_bind);
+
sg
_mutex_destroy(mutex);
}
static jfieldID jsynchro_field_Semaphore_bind;
}
static jfieldID jsynchro_field_Semaphore_bind;
@@
-55,39
+52,39
@@
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeInit(JNIEnv *env, jc
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_init(JNIEnv * env, jobject obj, jint capacity) {
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_init(JNIEnv * env, jobject obj, jint capacity) {
-
msg_sem_t sem = MSG_sem_init((int)
capacity);
+
sg_sem_t sem = sg_sem_init((int)
capacity);
env->SetLongField(obj, jsynchro_field_Semaphore_bind, (jlong)(uintptr_t)(sem));
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_acquire(JNIEnv * env, jobject obj, jdouble timeout) {
env->SetLongField(obj, jsynchro_field_Semaphore_bind, (jlong)(uintptr_t)(sem));
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_acquire(JNIEnv * env, jobject obj, jdouble timeout) {
-
m
sg_sem_t sem;
+ sg_sem_t sem;
- sem = (
m
sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
- msg_error_t res =
MSG
_sem_acquire_timeout(sem, (double)timeout) == 0 ? MSG_OK : MSG_TIMEOUT;
+ sem = (sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
+ msg_error_t res =
sg
_sem_acquire_timeout(sem, (double)timeout) == 0 ? MSG_OK : MSG_TIMEOUT;
if (res != MSG_OK) {
jmsg_throw_status(env, res);
}
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_release(JNIEnv * env, jobject obj) {
if (res != MSG_OK) {
jmsg_throw_status(env, res);
}
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_release(JNIEnv * env, jobject obj) {
-
m
sg_sem_t sem;
+ sg_sem_t sem;
- sem = (
m
sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
-
MSG
_sem_release(sem);
+ sem = (sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
+
sg
_sem_release(sem);
}
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * env, jobject obj) {
}
JNIEXPORT jboolean JNICALL Java_org_simgrid_msg_Semaphore_wouldBlock(JNIEnv * env, jobject obj) {
-
m
sg_sem_t sem;
+ sg_sem_t sem;
- sem = (
m
sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
- int res =
MSG
_sem_would_block(sem);
+ sem = (sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
+ int res =
sg
_sem_would_block(sem);
return (jboolean) res;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj) {
return (jboolean) res;
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Semaphore_nativeFinalize(JNIEnv * env, jobject obj) {
-
m
sg_sem_t sem;
+
const_
sg_sem_t sem;
- sem = (
m
sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
-
MSG
_sem_destroy(sem);
+ sem = (sg_sem_t)(uintptr_t)env->GetLongField(obj, jsynchro_field_Semaphore_bind);
+
sg
_sem_destroy(sem);
}
}