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

Method submitPacket

Engine/source/platform/async/asyncPacketQueue.h:255–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254template< typename Packet, typename TimeSource, typename Consumer, typename Tick >
255bool AsyncPacketQueue< Packet, TimeSource, Consumer, Tick >::submitPacket( Packet packet, TickType packetTicks, bool isLast, TickType packetPos )
256{
257 AssertFatal( mPacketQueue.capacity() != 0,
258 "AsyncPacketQueue::submitPacket() - Queue is full!" );
259
260 TickType packetStartPos;
261 TickType packetEndPos;
262
263 if( packetPos != TypeTraits< TickType >::MAX )
264 {
265 packetStartPos = packetPos;
266 packetEndPos = packetPos + packetTicks;
267 }
268 else
269 {
270 packetStartPos = mTotalQueuedTicks;
271 packetEndPos = mTotalQueuedTicks + packetTicks;
272 }
273
274 // Check whether the packet is outdated, if enabled.
275
276 bool dropPacket = false;
277 if( mDropPackets )
278 {
279 TickType currentTick = getCurrentTick();
280 if( currentTick >= packetEndPos )
281 dropPacket = true;
282 }
283
284 #ifdef DEBUG_SPEW
285 Platform::outputDebugString( "[AsyncPacketQueue] new packet #%i: %i-%i (ticks: %i, current: %i, queue: %i)%s",
286 mTotalQueuedPackets,
287 U32( mTotalQueuedTicks ),
288 U32( packetEndPos ),
289 U32( packetTicks ),
290 U32( getCurrentTick() ),
291 mPacketQueue.size(),
292 dropPacket ? " !! DROPPED !!" : "" );
293 #endif
294
295 // Queue the packet.
296
297 if( !dropPacket )
298 {
299 mPacketQueue.pushBack( QueuedPacket( packetStartPos, packetEndPos ) );
300 Deref( mConsumer ).write( &packet, 1 );
301 }
302
303 mTotalQueuedTicks = packetEndPos;
304 if( isLast && !mTotalTicks )
305 mTotalTicks = mTotalQueuedTicks;
306
307 mTotalQueuedPackets ++;
308
309 return !dropPacket;
310}
311
312#undef DEBUG_SPEW

Callers 2

refreshMethod · 0.80
updateMethod · 0.80

Calls 6

QueuedPacketClass · 0.85
U32Enum · 0.50
capacityMethod · 0.45
sizeMethod · 0.45
pushBackMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected