Пример #1
0
        public void RemoveReferences(int amount)
        {
            if (amount == 0)
            {
                return;
            }

            if (m_type != MsgType.Pool || (m_flags & MsgFlags.Shared) == 0)
            {
                Close();
            }

            if (m_atomicCounter.Decrement(amount) == 0)
            {
                m_atomicCounter.Dispose();
                m_atomicCounter = null;

                BufferPool.Return(m_data);
            }
        }
Пример #2
0
        public void Close()
        {
            if (!Check())
            {
                throw NetMQException.Create(ErrorCode.EFAULT);
            }

            if (m_type == MsgType.Pool)
            {
                // if not shared or reference counter drop to zero
                if ((m_flags & MsgFlags.Shared) == 0 || m_atomicCounter.Decrement() == 0)
                {
                    BufferPool.Return(m_data);
                }

                m_atomicCounter.Dispose();
                m_atomicCounter = null;
            }

            m_data = null;

            //  Make the message invalid.
            m_type = MsgType.Invalid;
        }