AsyncReadItem
Engine/source/platform/threads/threadPoolAsyncIO.h
Work item to asynchronously read from a stream.
Public Types
Parent::BufferType
BufferType
Parent::OffsetType
OffsetType
AsyncIOItem< T, Stream >
Parent
Parent::StreamType
StreamType
Parent::ValueType
ValueType
Protected Attributes
void *
Handle of asynchronous stream read, if we are using an async interface.
After the read operation has completed, this holds the number of elements actually read from the stream.
Public Functions
AsyncReadItem(StreamType * stream, U32 numElements, OffsetType offsetInStream, BufferType & buffer, bool takeOwnershipOfBuffer, U32 offsetInBuffer, ThreadContext * context)
AsyncReadItem(StreamType * stream, U32 numElements, OffsetType offsetInStream, ThreadContext * context)
Construct a read item that reads "numElements" at "offsetInStream" from "stream".
Protected Functions
_read(IAsyncInputStream< T > * stream)
_read(IInputStream< T > * stream)
_read(IOffsetInputStream< T > * stream)
Detailed Description
Work item to asynchronously read from a stream.
The given stream type may implement any of the input stream interfaces. Preference is given to IAsyncInputStream, then to IOffsetInputStream, and only if none of these are implemented IInputStream is used.
For IAsyncInputStreams, the async read operation is issued immediately on the constructing thread and then picked up on the worker thread. This ensures optimal use of concurrency.
Public Types
typedef Parent::BufferType BufferType
typedef Parent::OffsetType OffsetType
typedef AsyncIOItem< T, Stream > Parent
typedef Parent::StreamType StreamType
typedef Parent::ValueType ValueType
Protected Attributes
void * mAsyncHandle
Handle of asynchronous stream read, if we are using an async interface.
U32 mNumElementsRead
After the read operation has completed, this holds the number of elements actually read from the stream.
Public Functions
AsyncReadItem(StreamType * stream, U32 numElements, OffsetType offsetInStream, BufferType & buffer, bool takeOwnershipOfBuffer, U32 offsetInBuffer, ThreadContext * context)
AsyncReadItem(StreamType * stream, U32 numElements, OffsetType offsetInStream, ThreadContext * context)
Construct a read item that reads "numElements" at "offsetInStream" from "stream".
Since with this constructor no data buffer is supplied, it will be dynamically allocated by the read() method. Note that this only makes sense if this class is subclassed and processing is done on the buffer after it has been read.
Parameters:
stream | The stream to read from. |
numElement | The number of elements to read from the stream. |
offsetInStream | The offset at which to read from the stream; ignored if the stream uses implicit positioning |
context | The tread pool context to place the item into. |
getNumElementsRead()
The number of elements actually read from the stream.
Protected Functions
_allocBuffer()
_prep()
_read(IAsyncInputStream< T > * stream)
_read(IInputStream< T > * stream)
_read(IOffsetInputStream< T > * stream)
execute()
Reimplemented from: ThreadPool::WorkItem
Reimplemented by: AsyncPacketBufferedInputStream::PacketReadItem