Class
AssetChannel
View sourceCollects deferred reference-count operations for a typed asset pool in queue order.
Examples
import { AssetChannel, AssetChannelMessageType } from '@wimaengine/asset'
// An asset ID normally comes from a Handle<T>.id() call.
const assetId = 17
const channel = new AssetChannel()
channel.acquire(assetId)
const acquired = channel.flush()
channel.release(assetId)
const released = channel.flush()
console.log(acquired[0].type === AssetChannelMessageType.Acquire) // true
console.log(released[0].type === AssetChannelMessageType.Release) // trueConstructor
Methods
acquire(assetId: AssetId): void
View sourceQueue a reference acquisition for an asset ID.
Appends a new AssetChannelMessage with the
AssetChannelMessageType.Acquire label. Messages remain in call
order until AssetChannel#flush returns them; this method does not
apply the operation or change a reference count.
release(assetId: AssetId): void
View sourceQueue a reference release for an asset ID.
Appends a new AssetChannelMessage with the
AssetChannelMessageType.Release label. Messages remain in call
order until AssetChannel#flush returns them; this method does not
apply the operation or change a reference count.
flush(): readonly AssetChannelMessage<T>[]
View sourceReturn the pending message batch.
Returns the current queue array in append order. If the queue is non-empty, this channel replaces it with a new empty array, so later messages do not appear in the returned batch. If the queue is empty, the same empty array remains the channel’s queue and is returned. This method does not interpret the operation labels.
