Torque3D Documentation / _generateds / AsyncPacketQueue

AsyncPacketQueue

Engine/source/platform/async/asyncPacketQueue.h

Time-based packet stream queue.

More...

Classes:

class

Information about the time slice covered by an individual packet currently on the queue.

Public Types

TypeTraits< Consumer >::BaseType
ConsumerType 

The type of consumer that receives the packets from this queue.

TypeTraits< Packet >::BaseType
PacketType 

The type of data packets being streamed through this queue.

Parent 
Tick
TickType 

Type for counting ticks.

TypeTraits< TimeSource >::BaseType
TimeSourceType 

Protected Types

Protected Attributes

Consumer

The output stream that this queue feeds into.

bool

If true, packets that have missed their proper queuing timeframe will be dropped.

Queue that holds records for each packet currently in the queue.

TimeSource

The time source to which we are sync'ing.

Total number of packets queued so far.

Total number of ticks submitted to the queue so far.

Total number of ticks spanned by the total queue playback time.

Public Functions

AsyncPacketQueue(U32 maxQueuedPackets, TimeSource timeSource, Consumer consumer, TickType totalTicks, bool dropPackets)

Construct an AsyncPacketQueue of the given length.

Return the current playback position according to the time source.

Return the total number of packets that have been queued so far.

Return the total number of ticks that have been queued so far.

bool

Return true if all packets have been streamed.

bool

Return true if there are currently.

bool

Return true if the queue needs one or more new packets to be submitted.

bool
submitPacket(Packet packet, TickType packetTicks, bool isLast, TickType packetPos)

Submit a data packet to the queue.

Detailed Description

Time-based packet stream queue.

AsyncPacketQueue writes data packets to a consumer stream in sync to a tick time source. Outdated packets may optionally be dropped automatically by the queue. A fixed maximum number of packets can reside in the queue concurrently at any one time.

Be aware that using single item queues for synchronizing to a timer will usually result in bad timing behavior when packet uploading takes any non-trivial amount of time.

note:

While the queue associates a variable tick count with each individual packet, the queue fill status is measured in number of packets rather than in total tick time.

Parameters:
Packet

Value type of packets passed through this queue.

TimeSource

Value type for time tick source to which the queue is synchronized.

Consumer

Value type of stream to which the packets are written.

Public Types

typedef TypeTraits< Consumer >::BaseType ConsumerType 

The type of consumer that receives the packets from this queue.

typedef TypeTraits< Packet >::BaseType PacketType 

The type of data packets being streamed through this queue.

typedef void Parent 
typedef Tick TickType 

Type for counting ticks.

typedef TypeTraits< TimeSource >::BaseType TimeSourceType 

Protected Types

typedef FixedSizeDeque< QueuedPacket > PacketQueue 

Protected Attributes

Consumer mConsumer 

The output stream that this queue feeds into.

bool mDropPackets 

If true, packets that have missed their proper queuing timeframe will be dropped.

If false, they will be queued nonetheless.

PacketQueue mPacketQueue 

Queue that holds records for each packet currently in the queue.

New packets are added to back.

TimeSource mTimeSource 

The time source to which we are sync'ing.

U32 mTotalQueuedPackets 

Total number of packets queued so far.

TickType mTotalQueuedTicks 

Total number of ticks submitted to the queue so far.

TickType mTotalTicks 

Total number of ticks spanned by the total queue playback time.

If this is zero, the total queue time is considered to be infinite.

Public Functions

AsyncPacketQueue(U32 maxQueuedPackets, TimeSource timeSource, Consumer consumer, TickType totalTicks, bool dropPackets)

Construct an AsyncPacketQueue of the given length.

Parameters:

maxQueuedPackets

The length of the queue in packets. Only a maximum of 'maxQueuedPackets' packets can be concurrently in the queue at any one time.

timeSource

The tick time source to which the queue synchronizes.

consumer

The output stream that receives the packets in sync to timeSource.

totalTicks

The total number of ticks that will be played back through the queue; if 0, the length is considered indefinite.

dropPackets

Whether the queue should drop outdated packets; if dropped, a packet will not reach the consumer.

getCurrentTick()

Return the current playback position according to the time source.

getTotalQueuedPackets()

Return the total number of packets that have been queued so far.

getTotalQueuedTicks()

Return the total number of ticks that have been queued so far.

isAtEnd()

Return true if all packets have been streamed.

isEmpty()

Return true if there are currently.

needPacket()

Return true if the queue needs one or more new packets to be submitted.

submitPacket(Packet packet, TickType packetTicks, bool isLast, TickType packetPos)

Submit a data packet to the queue.

Parameters:

packet

The data packet.

packetTicks

The duration of the packet in ticks.

isLast

If true, the packet is the last one in the stream.

packetPos

The absolute position of the packet in the stream; if this is not supplied the packet is assumed to immediately follow the preceding packet.

return:

true if the packet has been queued or false if it has been dropped.