Skip to content

Commit

Permalink
Remove use of Cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis committed Feb 26, 2024
1 parent 1c484eb commit 0a86f96
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions aws-crt-kotlin/native/src/aws/sdk/kotlin/crt/CrtResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package aws.sdk.kotlin.crt
import kotlinx.cinterop.*
import libcrt.*
import kotlin.experimental.ExperimentalNativeApi
import kotlin.native.concurrent.freeze
import kotlin.native.ref.createCleaner

@OptIn(ExperimentalForeignApi::class)
Expand All @@ -27,13 +28,13 @@ public abstract class CrtResource<T: CPointed> : CValuesRef<T>() {
)
}

// FIXME is `ptr` the thing this cleaner should be referencing, or something else?
@OptIn(ExperimentalNativeApi::class)
internal val cleaner = createCleaner(ptr) {
aws_ref_count_release(rc)
}

// FIXME do we need to provide explicit acquire/release if we use a cleaner?
/**
* Acquire a reference to this resource
*/
public fun acquire() { aws_ref_count_acquire(rc) }

/**
* Release a previously-acquired reference to this resource
*/
public fun release() { aws_ref_count_release(rc) }
}

0 comments on commit 0a86f96

Please sign in to comment.