internal void Recycle(NetOutgoingMessage msg) { if (m_outgoingMessagesPool == null) { return; } #if DEBUG NetException.Assert(m_outgoingMessagesPool.Contains(msg) == false, "Recyling already recycled outgoing message! Thread race?"); if (msg.m_recyclingCount != 0) { LogWarning("Wrong recycling count! should be zero; found " + msg.m_recyclingCount); } #endif // setting m_recyclingCount to zero SHOULD be an unnecessary maneuver, if it's not zero something is wrong // however, in RELEASE, we'll just have to accept this and move on with life msg.m_recyclingCount = 0; byte[] storage = msg.m_data; msg.m_data = null; // message fragments cannot be recycled // TODO: find a way to recycle large message after all fragments has been acknowledged; or? possibly better just to garbage collect them if (msg.m_fragmentGroup == 0) { Recycle(storage); } msg.Reset(); if (m_outgoingMessagesPool.Count < m_maxCacheCount) { m_outgoingMessagesPool.Enqueue(msg); } }
internal void Recycle(NetOutgoingMessage msg) { if (m_outgoingMessagesPool == null) { return; } #if DEBUG if (m_outgoingMessagesPool.Contains(msg)) { throw new NetException("Recyling already recycled message! Thread race?"); } #endif byte[] storage = msg.m_data; msg.m_data = null; // message fragments cannot be recycled // TODO: find a way to recycle large message after all fragments has been acknowledged; or? possibly better just to garbage collect them if (msg.m_fragmentGroup == 0) { Recycle(storage); } msg.Reset(); m_outgoingMessagesPool.Enqueue(msg); }
internal void Recycle(NetOutgoingMessage msg) { if (m_outgoingMessagesPool == null) { return; } NetException.Assert(msg.m_recyclingCount == 0, "Wrong recycling count! Should be zero"); NetException.Assert(m_outgoingMessagesPool.Contains(msg) == false, "Recyling already recycled message! Thread race?"); byte[] storage = msg.m_data; msg.m_data = null; // message fragments cannot be recycled // TODO: find a way to recycle large message after all fragments has been acknowledged; or? possibly better just to garbage collect them if (msg.m_fragmentGroup == 0) { Recycle(storage); } msg.Reset(); if (m_outgoingMessagesPool.Count < m_maxCacheCount) { m_outgoingMessagesPool.Enqueue(msg); } }
internal void Recycle(NetOutgoingMessage msg) { if (m_outgoingMessagesPool == null) return; #if DEBUG if (m_outgoingMessagesPool.Contains(msg)) throw new NetException("Recyling already recycled message! Thread race?"); #endif byte[] storage = msg.m_data; msg.m_data = null; // message fragments cannot be recycled // TODO: find a way to recycle large message after all fragments has been acknowledged; or? possibly better just to garbage collect them if (msg.m_fragmentGroup == 0) Recycle(storage); msg.Reset(); m_outgoingMessagesPool.Enqueue(msg); }
internal void Recycle(NetOutgoingMessage msg) { if (m_outgoingMessagesPool == null) return; #if DEBUG NetException.Assert(m_outgoingMessagesPool.Contains(msg) == false, "Recyling already recycled outgoing message! Thread race?"); if (msg.m_recyclingCount != 0) LogWarning("Wrong recycling count! should be zero; found " + msg.m_recyclingCount); #endif // setting m_recyclingCount to zero SHOULD be an unnecessary maneuver, if it's not zero something is wrong // however, in RELEASE, we'll just have to accept this and move on with life msg.m_recyclingCount = 0; byte[] storage = msg.m_data; msg.m_data = null; // message fragments cannot be recycled // TODO: find a way to recycle large message after all fragments has been acknowledged; or? possibly better just to garbage collect them if (msg.m_fragmentGroup == 0) Recycle(storage); msg.Reset(); if (m_outgoingMessagesPool.Count < m_maxCacheCount) m_outgoingMessagesPool.Enqueue(msg); }