API reference
API reference
Select your platform
No SDKs available
No versions available

GlobalLastUpdate Object

Provides atomic access to a global lastUpdate counter shared between C++ and Kotlin via a DirectByteBuffer backed by native memory.
Reads (GlobalLastUpdate.get) are JNI-free — they go straight to the shared native memory through the ByteBuffer. Atomic increments (GlobalLastUpdate.incAndGet) use a @CriticalNative JNI call (~25 ns, ~5x faster than regular JNI) into the C++ singleton.
TODO: When the compile SDK is bumped to 33+, replace the JNI increment with a fully JNI-free VarHandle.getAndAdd path via MethodHandles.byteBufferViewVarHandle(LongArray::class.java, ByteOrder.nativeOrder()). VarHandle provides atomic read-modify-write directly on a DirectByteBuffer without crossing the JNI boundary.

Signature

object GlobalLastUpdate

Methods

get ()
Read the current global lastUpdate version directly from shared memory (no JNI).
Signature
fun get(): ULong
Returns
ULong
incAndGet ()
Atomically increment the global lastUpdate counter and return the new value.
Signature
fun incAndGet(): ULong
Returns
ULong