PacketConsumer


@ExperimentalApi
interface PacketConsumer<T : Any?>

Known direct subclasses
RecordingPacketConsumer

A PacketConsumer implementation that holds a reference to all queued packets, and optionally releases the underlying frames.


A consumer that accepts Packets.

This interface is experimental and will be renamed or removed in a future release.

Parameters
<T : Any?>

The type of Packet.payload being consumed.

Summary

Nested types

fun interface PacketConsumer.Factory<T : Any?>

A factory for PacketConsumer instances.

interface PacketConsumer.Packet<T : Any?>

Represents a data packet that wraps a payload.

Public functions

suspend Unit

Queues a Packet for processing, suspending the caller if the consumer is at capacity.

suspend Unit

Releases all resources.

Boolean

Attempts to queue a Packet for processing without blocking.

Public functions

queuePacket

suspend fun queuePacket(packet: PacketConsumer.Packet<T>): Unit

Queues a Packet for processing, suspending the caller if the consumer is at capacity.

Once this method returns, the ownership of the packet is transferred to this PacketConsumer, and the caller should not modify the packet.

Parameters
packet: PacketConsumer.Packet<T>

The Packet to process.

release

suspend fun release(): Unit

Releases all resources.

tryQueuePacket

fun tryQueuePacket(packet: PacketConsumer.Packet<T>): Boolean

Attempts to queue a Packet for processing without blocking.

If this method returns true, the ownership of the packet is transferred to this PacketConsumer and the caller must not modify the packet.

Parameters
packet: PacketConsumer.Packet<T>

The Packet to process.

Returns
Boolean

true if the packet was accepted and queued for processing. Returns false if the consumer is at capacity and cannot accept the packet at this time.