MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / _requestNext

Method _requestNext

Engine/source/platform/async/asyncPacketStream.h:274–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272
273template< typename Stream, class Packet >
274void AsyncPacketBufferedInputStream< Stream, Packet >::_requestNext()
275{
276 Stream& stream = this->getSourceStream();
277 bool isEOS = !this->mNumRemainingSourceElements;
278 if( isEOS && this->mIsLooping )
279 {
280 StreamType* s = &Deref( stream );
281 IResettable* resettable = dynamic_cast< IResettable* >( s );
282 if( resettable )
283 {
284 resettable->reset();
285 isEOS = false;
286 this->mNumRemainingSourceElements = mNumTotalSourceElements;
287 }
288 }
289 else if( isEOS )
290 return;
291
292 //TODO: scale priority depending on feed status
293
294 // Allocate a packet.
295
296 U32 numElements = mPacketSize;
297 PacketType* packet = _newPacket( numElements );
298 packet->mIndex = mNextPacketIndex;
299 mNextPacketIndex ++;
300
301 // Queue a stream packet work item.
302
303 if( numElements >= this->mNumRemainingSourceElements )
304 {
305 if( !this->mIsLooping )
306 {
307 this->mNumRemainingSourceElements = 0;
308 packet->mIsLast = true;
309 }
310 else
311 this->mNumRemainingSourceElements = ( this->mNumTotalSourceElements - numElements + this->mNumRemainingSourceElements );
312 }
313 else
314 this->mNumRemainingSourceElements -= numElements;
315
316 #ifdef DEBUG_SPEW
317 Platform::outputDebugString( "[AsyncPacketStream] packet %i, %i remaining, %i total",
318 packet->mIndex, this->mNumRemainingSourceElements, mNumTotalSourceElements );
319 #endif
320
321 ThreadSafeRef< PacketReadItem > workItem;
322 _newReadItem( workItem, packet, numElements );
323 this->mThreadPool->queueWorkItem( workItem );
324}
325
326#undef DEBUG_SPEW
327#endif // !_ASYNCPACKETSTREAM_H_

Callers

nothing calls this directly

Calls 2

queueWorkItemMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected