Skip to content

Commit 6d05f88

Browse files
committed
close renamed to free
1 parent bba19cb commit 6d05f88

9 files changed

Lines changed: 20 additions & 20 deletions

File tree

prebindgen-ext/src/jni/jni_kotlin_ext.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -518,14 +518,14 @@ import kotlin.concurrent.write
518518
* Race-free wrapper around a raw `Box<T>` pointer obtained from native
519519
* code via `Box::into_raw(Box::new(v))`. Pairs the pointer with a
520520
* `ReentrantReadWriteLock` so that borrow-style JNI calls run in
521-
* parallel under the read lock and consume/close serialise against
521+
* parallel under the read lock and consume/free serialise against
522522
* them under the write lock.
523523
*
524524
* This is the Java-side half of the type-conversion rule for opaque
525525
* handles: `&T` parameters route through [withPtr] (borrow); by-value
526526
* `T` parameters route through [consume] (write lock, slot stays
527527
* valid during the action, then null-ed in `finally`); destructor
528-
* entry points without a matching `#[prebindgen]` fn use [close]. The
528+
* entry points without a matching `#[prebindgen]` fn use [free]. The
529529
* auto-generated wrappers in `JNIWrappers.kt` are the only callers
530530
* that need to know which mode applies.
531531
*
@@ -536,13 +536,13 @@ public open class NativeHandle(initial: Long) {
536536
private val lock = ReentrantReadWriteLock()
537537
538538
/** Volatile so [peek] is atomic on 32-bit JVMs and observes the
539-
* write done by [close] / [consume] without holding the lock. */
539+
* write done by [free] / [consume] without holding the lock. */
540540
@Volatile private var ptr: Long = initial
541541
542542
/**
543543
* Run [block] with the live pointer under the read lock. Throws
544-
* [ZError] if [close] has already released the handle. Multiple
545-
* concurrent invocations run in parallel; only [close]/[consume]
544+
* [ZError] if [free] has already released the handle. Multiple
545+
* concurrent invocations run in parallel; only [free]/[consume]
546546
* are serialised against them.
547547
*/
548548
@Throws(ZError::class)
@@ -554,10 +554,10 @@ public open class NativeHandle(initial: Long) {
554554
555555
/**
556556
* Take the pointer under the write lock and pass it to [freeFn]
557-
* exactly once. Subsequent [close] calls are no-ops. Blocks until
557+
* exactly once. Subsequent [free] calls are no-ops. Blocks until
558558
* all in-flight [withPtr] calls finish.
559559
*/
560-
public fun close(freeFn: (Long) -> Unit) {
560+
public fun free(freeFn: (Long) -> Unit) {
561561
lock.write {
562562
val p = ptr
563563
if (p == 0L) return@write
@@ -577,9 +577,9 @@ public open class NativeHandle(initial: Long) {
577577
* typed handle to JNI and have JNI extract the pointer via [peek]
578578
* — symmetric with [withPtr] for the Borrow path. Unique-ownership
579579
* is still guaranteed: the write lock excludes every other
580-
* [withPtr] / [consume] / [close], and the `finally` clause
580+
* [withPtr] / [consume] / [free], and the `finally` clause
581581
* unconditionally nulls the slot before the lock is released, so
582-
* the next [withPtr] / [consume] / [close] sees `ptr == 0` and
582+
* the next [withPtr] / [consume] / [free] sees `ptr == 0` and
583583
* cannot reach the freed allocation.
584584
*
585585
* Throws if the handle has already been closed/consumed.
@@ -595,7 +595,7 @@ public open class NativeHandle(initial: Long) {
595595
}
596596
}
597597
598-
/** True iff [close] has run. */
598+
/** True iff [free] has run. */
599599
public fun isClosed(): Boolean = lock.read { ptr == 0L }
600600
601601
/**
@@ -612,7 +612,7 @@ public open class NativeHandle(initial: Long) {
612612
///
613613
/// ```kotlin
614614
/// public class JNIFoo(initialPtr: Long) : NativeHandle(initialPtr) {
615-
/// public fun close() = close { freePtrViaJNI(it) }
615+
/// public fun free() = free { freePtrViaJNI(it) }
616616
/// private external fun freePtrViaJNI(ptr: Long)
617617
/// }
618618
/// ```
@@ -709,7 +709,7 @@ fn render_typed_handle_source(
709709
"public class {}(initialPtr: Long) : NativeHandle(initialPtr) {{\n",
710710
class_name
711711
));
712-
s.push_str(" public fun close() = close { freePtrViaJNI(it) }\n");
712+
s.push_str(" public fun free() = free { freePtrViaJNI(it) }\n");
713713
s.push_str(" private external fun freePtrViaJNI(ptr: Long)\n");
714714
if !methods_body.is_empty() {
715715
s.push('\n');

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIAdvancedPublisher.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class JNIAdvancedPublisher(initialPtr: Long) : NativeHandle(initialPtr) {
4242
@Throws(ZError::class)
4343
fun getMatchingStatus(): Boolean = withPtr { ptr -> getMatchingStatusViaJNI(ptr) }
4444

45-
fun close() = close { freePtrViaJNI(it) }
45+
fun free() = free { freePtrViaJNI(it) }
4646

4747
@Throws(ZError::class)
4848
private external fun putViaJNI(

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIAdvancedSubscriber.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class JNIAdvancedSubscriber(initialPtr: Long) : NativeHandle(initialPtr)
5656
declareBackgroundSampleMissListenerViaJNI(ptr, callback, onClose)
5757
}
5858

59-
fun close() = close { freePtrViaJNI(it) }
59+
fun free() = free { freePtrViaJNI(it) }
6060

6161
@Throws(ZError::class)
6262
private external fun declareDetectPublishersSubscriberViaJNI(

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class JNIConfig(initialPtr: Long) : NativeHandle(initialPtr) {
6868
private external fun getJsonViaJNI(ptr: Long, key: String): String
6969
}
7070

71-
fun close() = close { freePtrViaJNI(it) }
71+
fun free() = free { freePtrViaJNI(it) }
7272

7373
@Throws(ZError::class)
7474
fun getId(): ByteArray = withPtr { ptr -> getIdViaJNI(ptr) }

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIKeyExpr.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ fun keyExprConcat(a: NativeHandle?, aStr: String, other: String): KeyExprResult
8888
* has already been closed/consumed.
8989
*/
9090
fun keyExprDrop(handle: NativeHandle) {
91-
handle.close { ptr -> JNINative.dropKeyExprViaJNI(ptr) }
91+
handle.free { ptr -> JNINative.dropKeyExprViaJNI(ptr) }
9292
}

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNILivelinessToken.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ package io.zenoh.jni
1616

1717
/** Typed [NativeHandle] for a native Zenoh `LivelinessToken`. */
1818
public class JNILivelinessToken(initialPtr: Long) : NativeHandle(initialPtr) {
19-
fun undeclare() = close { undeclareViaJNI(it) }
19+
fun undeclare() = free { undeclareViaJNI(it) }
2020
private external fun undeclareViaJNI(ptr: Long)
2121
}

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIQuerier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ public class JNIQuerier(initialPtr: Long) : NativeHandle(initialPtr) {
6060

6161
private external fun freePtrViaJNI(ptr: Long)
6262

63-
fun close() = close { freePtrViaJNI(it) }
63+
fun free() = free { freePtrViaJNI(it) }
6464
}

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIQuery.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class JNIQuery(initialPtr: Long) : NativeHandle(initialPtr) {
6363
}
6464
}
6565

66-
fun close() = close { freePtrViaJNI(it) }
66+
fun free() = free { freePtrViaJNI(it) }
6767

6868
@Throws(ZError::class)
6969
private external fun replySuccessViaJNI(

zenoh-jni-runtime/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ public class JNIScout(initialPtr: Long) : NativeHandle(initialPtr) {
5252
private external fun freePtrViaJNI(ptr: Long)
5353
}
5454

55-
fun close() = close { freePtrViaJNI(it) }
55+
fun free() = free { freePtrViaJNI(it) }
5656
}

0 commit comments

Comments
 (0)