AtomicNativePtr

class AtomicNativePtr(var value: NativePtr)(source)

A kotlinx.cinterop.NativePtr that may be updated atomically.

Read operation load has the same memory effects as reading a Volatile property; Write operation store has the same memory effects as writing a Volatile property; Read-modify-write operations, like exchange, compareAndSet, compareAndExchange, have the same memory effects as reading and writing a Volatile property.

For additional details about atomicity guarantees for reads and writes see kotlin.concurrent.Volatile.

kotlinx.cinterop.NativePtr is a value type, hence it is stored in AtomicNativePtr without boxing and compareAndSet, compareAndExchange operations perform comparison by value.

Since Kotlin

2.1

Constructors

Link copied to clipboard
constructor(value: NativePtr)

Properties

Link copied to clipboard
var value: NativePtr
Since Kotlin 2.1

Functions

Link copied to clipboard
fun compareAndExchange(expectedValue: NativePtr, newValue: NativePtr): NativePtr

Atomically stores the given new value into this AtomicNativePtr if the current value equals the expected value and returns the old value in any case.

Since Kotlin 2.1
Link copied to clipboard
fun compareAndSet(expectedValue: NativePtr, newValue: NativePtr): Boolean

Atomically stores the given new value into this AtomicNativePtr if the current value equals the expected value, returns true if the operation was successful and false only if the current value was not equal to the expected value.

Since Kotlin 2.1
Link copied to clipboard
fun exchange(newValue: NativePtr): NativePtr

Atomically stores the given new value into this AtomicNativePtr and returns the old value.

Since Kotlin 2.1
Link copied to clipboard
fun getAndSet(newValue: NativePtr): NativePtr

Atomically sets the value to the given new value and returns the old value.

Since Kotlin 2.1
Link copied to clipboard
fun load(): NativePtr

Atomically loads the value from this AtomicNativePtr.

Since Kotlin 2.1
Link copied to clipboard
fun store(newValue: NativePtr)

Atomically stores the new value into this AtomicNativePtr.

Since Kotlin 2.1
Link copied to clipboard
open override fun toString(): String

Returns the string representation of the underlying NativePtr.

Since Kotlin 2.1