1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-16 23:26:32 +09:00

m_needFlushSendQueue added to prevent traversing sender channels each heartbeat

This commit is contained in:
Michael Lidgren
2015-01-20 17:39:03 +01:00
parent f95a6e02c4
commit d57f7045fe
6 changed files with 24 additions and 7 deletions

View File

@@ -52,6 +52,7 @@ namespace Lidgren.Network
internal override NetSendResult Enqueue(NetOutgoingMessage message)
{
m_queuedSends.Enqueue(message);
m_connection.m_peer.m_needFlushSendQueue = true; // a race condition to this variable will simply result in a single superflous call to FlushSendQueue()
if (m_queuedSends.Count <= GetAllowedSends())
return NetSendResult.Sent;
return NetSendResult.Queued;
@@ -100,7 +101,7 @@ namespace Lidgren.Network
return;
// queued sends
while (m_queuedSends.Count > 0 && num > 0)
while (num > 0 && m_queuedSends.Count > 0)
{
NetOutgoingMessage om;
if (m_queuedSends.TryDequeue(out om))