You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-15 22:56:30 +09:00
- ReadMessages() added to batch read messages. Image sample changed to use the new batch method.
This commit is contained in:
@@ -148,6 +148,28 @@ namespace Lidgren.Network
|
||||
m_incomingMessagesPool.Enqueue(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recycles a list of NetIncomingMessage instances for reuse; taking pressure off the garbage collector
|
||||
/// </summary>
|
||||
public void Recycle(IEnumerable<NetIncomingMessage> toRecycle)
|
||||
{
|
||||
if (m_incomingMessagesPool == null)
|
||||
return;
|
||||
|
||||
foreach (var msg in toRecycle)
|
||||
{
|
||||
#if DEBUG
|
||||
if (m_incomingMessagesPool.Contains(msg))
|
||||
throw new NetException("Recyling already recycled message! Thread race?");
|
||||
#endif
|
||||
byte[] storage = msg.m_data;
|
||||
msg.m_data = null;
|
||||
Recycle(storage);
|
||||
msg.Reset();
|
||||
m_incomingMessagesPool.Enqueue(msg);
|
||||
}
|
||||
}
|
||||
|
||||
internal void Recycle(NetOutgoingMessage msg)
|
||||
{
|
||||
if (m_outgoingMessagesPool == null)
|
||||
|
||||
Reference in New Issue
Block a user