示例#1
0
        public override void ReturnPacket(SNIPacket packet)
        {
#if DEBUG
            Debug.Assert(packet != null, "releasing null SNIPacket");
            Debug.Assert(packet.IsActive, "SNIPacket _refcount must be 1 or a lifetime issue has occurred, trace with the #TRACE_HISTORY define");
            Debug.Assert(ReferenceEquals(packet._owner, this), "releasing SNIPacket that belongs to another physical handle");
            Debug.Assert(!packet.IsInvalid, "releasing already released SNIPacket");
#endif

            packet.Release();
#if DEBUG
            Interlocked.Add(ref packet._refCount, -1);
            packet._traceTag = null;
#if TRACE_HISTORY
            if (packet._history != null)
            {
                packet._history.Add(new SNIPacket.History {
                    Action = SNIPacket.History.Direction.Return, Stack = GetStackParts(), RefCount = packet._refCount
                });
            }
#endif
            GC.SuppressFinalize(packet);
#endif
            _pool.Return(packet);
        }
示例#2
0
        public override void ReturnPacket(SNIPacket packet)
        {
            Debug.Assert(packet != null, "releasing null SNIPacket");
#if DEBUG
            Debug.Assert(packet.IsActive, "SNIPacket _refcount must be 1 or a lifetime issue has occured, trace with the #TRACE_HISTORY define");
            Debug.Assert(ReferenceEquals(packet._owner, this), "releasing SNIPacket that belongs to another physical handle");
#endif
            Debug.Assert(!packet.IsInvalid, "releasing already released SNIPacket");

            packet.Release();
#if DEBUG
            Interlocked.Add(ref packet._refCount, -1);
            packet._traceTag = null;
            packet.AddHistory(false);
            GC.SuppressFinalize(packet);
#endif
            _pool.Return(packet);
        }