SharedBuffer class abstract interface

A fixed-length block of memory that is shared (not copied) when sent to a worker, with a small atomic-integer API on top.

Only usable when the page is cross-origin isolated (COOP/COEP headers — see the README section "SharedArrayBuffer and cross-origin isolation"). Check isSupported or use tryAllocate; both never throw on any platform. The typed-data accessors return views: writes through them and through the atomic methods are visible to every agent holding the buffer.

A SharedBuffer may be placed anywhere inside a WorkerPool task payload and arrives in the worker as a view of the same memory.

Implementers

Constructors

SharedBuffer.allocate(int byteLength)
Allocates byteLength bytes of shared memory.
factory

Properties

byteLength → int
Total length of the buffer, in bytes.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

asFloat64List() → Float64List
A 64-bit float view over the buffer (byteLength ~/ 8 elements).
asInt32List() → Int32List
A signed 32-bit view over the buffer (byteLength ~/ 4 elements).
asUint8List() → Uint8List
A byte view over the whole buffer.
atomicAdd(int index, int value) → int
Atomically adds value to the 32-bit element at index and returns the previous value. index is in Int32 elements, not bytes.
atomicLoad(int index) → int
Atomically reads the 32-bit element at index.
atomicStore(int index, int value) → void
Atomically writes value to the 32-bit element at index.
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

Static Properties

isSupported → bool
Whether shared memory can be allocated here. false off the web and on non-isolated pages; never throws.
no setter

Static Methods

tryAllocate(int byteLength) → SharedBuffer?
Allocates byteLength bytes of shared memory, or returns null where unsupported — the never-throwing counterpart of SharedBuffer.allocate.