diff --git a/jni-utils/src/commonMain/kotlin/io/github/landrynorris/jniutils/MonitorOperations.kt b/jni-utils/src/commonMain/kotlin/io/github/landrynorris/jniutils/MonitorOperations.kt index 276d0a0..82851e6 100644 --- a/jni-utils/src/commonMain/kotlin/io/github/landrynorris/jniutils/MonitorOperations.kt +++ b/jni-utils/src/commonMain/kotlin/io/github/landrynorris/jniutils/MonitorOperations.kt @@ -5,11 +5,21 @@ import platform.android.JNIEnvVar import platform.android.JNINativeMethod import platform.android.jobject +/** + * Enter the monitor owned by obj + * + * Do not mix JNI [monitorExit] with Java synchronized method + */ fun CPointer.monitorEnter(obj: jobject) { val method = pointed.pointed?.MonitorEnter ?: error("JNI is not Oracle standard") method.invoke(this, obj) } +/** + * The current thread must be the owner of the monitor associated with obj. + * + * Do not mix JNI [monitorExit] with Java synchronized method + */ fun CPointer.monitorExit(obj: jobject) { val method = pointed.pointed?.MonitorExit ?: error("JNI is not Oracle standard") method.invoke(this, obj)