PacketConsumer


@ExperimentalApi
public interface PacketConsumer<T extends Object>

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 extends Object>

The type of Packet.payload being consumed.

Summary

Nested types

public fun interface PacketConsumer.Factory<T extends Object>

A factory for PacketConsumer instances.

public interface PacketConsumer.Packet<T extends Object>

Represents a data packet that wraps a payload.

Public methods

abstract void

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

abstract void

Releases all resources.

abstract boolean

Attempts to queue a Packet for processing without blocking.

Public methods

queuePacket

abstract void queuePacket(@NonNull PacketConsumer.Packet<@NonNull T> packet)

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
@NonNull PacketConsumer.Packet<@NonNull T> packet

The Packet to process.

release

abstract void release()

Releases all resources.

tryQueuePacket

abstract boolean tryQueuePacket(@NonNull PacketConsumer.Packet<@NonNull T> packet)

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
@NonNull PacketConsumer.Packet<@NonNull T> packet

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.