ReleaseToken class
PR #5: stable handle for a buffer the Rust pool owns. The Dart
side can hand the underlying Uint8List directly to a texture
(no copy), and when the parent ReleaseToken becomes
unreachable, a Finalizer returns the buffer to the Rust pool
via bufferPoolReleaseByToken.
Why a token? The Rust buffer pool is a single shared
best-fit free list, so a "raw pointer" would be ambiguous —
the same Vec<u8> could be sitting in the pool or in
someone else's hand. A monotonically increasing token gives the
Rust side a stable identifier for telemetry and lets the
Finalizer fire-and-forget (the token is opaque to Dart, so
there's no risk of a misuse causing a wrong-pointer write).
Use via ReleaseToken.fromBytes or ReleaseToken.fromPreview.
Constructors
- ReleaseToken.fromBytes({required Uint8List bytes, required BigInt token})
-
Build a
ReleaseTokenfrom a Uint8List + token. Prefer fromPreview in real code; this constructor exists for tests and for cases where the buffer comes from a non-preview path.factory - ReleaseToken.fromPreview(PreviewFrameRgbaBuf frame)
-
Build a
ReleaseTokenfrom aPreviewFrameRgbaBuf. Thergbafield's underlying buffer is the Rust-owned data, so we hand it to the Finalizer directly.factory
Properties
Methods
-
detach(
) → void -
Drop the token without releasing the buffer. After this, the
buffer will be returned to the pool by the next call to
bufferPoolRelease / bufferPoolReleaseByToken from the
app, or when Rust drops its reference. Use when you want to
keep the buffer alive past the
ReleaseToken's lifetime (e.g. hand it to a worker isolate). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited