use<R> method

R use<R>(
  1. R fn(
    1. Pointer<T> ptr
    )
)

Invokes fn with the underlying Pointer<T>, keeping this reachable until fn completes so the GC finalizer cannot run mid-call.

Implementation

R use<R>(R Function(ffi.Pointer<T> ptr) fn) {
  if (_disposed) {
    throw StateError('NativeHandle<$T> has already been disposed');
  }
  return fn(_ptr);
}