Torque3D Documentation / _generateds / AsyncPacketBufferedInputStream

AsyncPacketBufferedInputStream

Engine/source/platform/async/asyncPacketStream.h

A packet stream turns a continuous stream of elements into a stream of discrete packets of elements.

More...

Classes:

class

Asynchronous work item for reading a packet from the source stream.

Public Types

Packet
PacketType 
Parent 
TypeTraits< Stream >::BaseType
StreamType 

Protected Types

PacketReadItemRef 

Public Friends

Protected Attributes

Running number of next stream packet.

Total number of elements in the source stream.

Number of elements to read per packet.

Protected Functions

_newPacket(U32 packetSize)

Create a new stream packet of the given size.

_newReadItem(PacketReadItemRef & outRef, PacketType * packet, U32 numElements)

Create a new work item that reads "numElements" into "packet".

Request the next packet from the underlying stream.

Public Functions

AsyncPacketBufferedInputStream(const Stream & stream, U32 packetSize, U32 numSourceElementsToRead, U32 numReadAhead, bool isLooping, ThreadPool * pool, ThreadContext * context)

Construct a new packet stream reading from "stream".

Detailed Description

A packet stream turns a continuous stream of elements into a stream of discrete packets of elements.

All packets are of the exact same size even if, for end-of-stream packets, they actually contain less data than their actual size. Extraneous space is cleared.

note:

For looping streams, the stream must implement the IResettable interface.

Public Types

typedef Packet PacketType 
typedef AsyncBufferedInputStream< Packet *, Stream > Parent 
typedef TypeTraits< Stream >::BaseType StreamType 

Protected Types

typedef ThreadSafeRef< PacketReadItem > PacketReadItemRef 

Public Friends

Protected Attributes

U32 mNextPacketIndex 

Running number of next stream packet.

U32 mNumTotalSourceElements 

Total number of elements in the source stream.

U32 mPacketSize 

Number of elements to read per packet.

Protected Functions

_newPacket(U32 packetSize)

Create a new stream packet of the given size.

Reimplemented by: SFXInternal::SFXAsyncStream

_newReadItem(PacketReadItemRef & outRef, PacketType * packet, U32 numElements)

Create a new work item that reads "numElements" into "packet".

_requestNext()

Reimplemented from: AsyncBufferedInputStream

Reimplemented by: SFXInternal::SFXAsyncStream

Public Functions

AsyncPacketBufferedInputStream(const Stream & stream, U32 packetSize, U32 numSourceElementsToRead, U32 numReadAhead, bool isLooping, ThreadPool * pool, ThreadContext * context)

Construct a new packet stream reading from "stream".

note:

If looping is used and "stream" is not read from the beginning, "stream" should implement IPositionable or ISizeable so the async stream can tell how many elements there actually are in the stream after resetting.

Parameters:
stream

The source stream from which to read the actual data elements.

packetSize

Size of stream packets returned by the stream in number of elements.

numSourceElementsToRead

Number of elements to read from "stream".

numReadAhead

Number of packets to read and buffer in advance.

isLooping

If true, the packet stream will loop infinitely over the source stream.

pool

The ThreadPool to use for asynchronous packet reads.

context

The ThreadContext to place asynchronous packet reads in.

getPacketSize()

return:

the size of stream packets returned by this stream in number of elements.