MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / read

Method read

Engine/source/platform/async/asyncBufferedStream.h:236–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234
235template< typename T, typename Stream >
236U32 AsyncBufferedInputStream< T, Stream >::read( ElementType* buffer, U32 num )
237{
238 if( !num )
239 return 0;
240
241 U32 numRead = 0;
242 for( U32 i = 0; i < num; ++ i )
243 {
244 // Try to pop a element off the buffered element list.
245
246 ElementType element;
247 if( mBufferedElements.tryPopFront( element ) )
248 {
249 buffer[ i ] = element;
250 numRead ++;
251 }
252 else
253 break;
254 }
255
256 // Get the request chain going again, if it has stopped.
257
258 while( 1 )
259 {
260 U32 numBuffered = mNumBufferedElements;
261 U32 newNumBuffered = numBuffered - numRead;
262
263 if( dCompareAndSwap( mNumBufferedElements, numBuffered, newNumBuffered ) )
264 {
265 if( numBuffered == mMaxBufferedElements )
266 _requestNext();
267
268 break;
269 }
270 }
271
272 return numRead;
273}
274
275
276//=============================================================================

Callers 3

executeMethod · 0.45
_readMethod · 0.45
unpackUpdateMethod · 0.45

Calls 2

dCompareAndSwapFunction · 0.50
tryPopFrontMethod · 0.45

Tested by

no test coverage detected