Beispiel #1
0
        public void AddReferences(int amount)
        {
            if (amount == 0)
            {
                return;
            }

            if (m_type == MsgType.Pool)
            {
                if (m_flags == MsgFlags.Shared)
                {
                    m_atomicCounter.Increase(amount);
                }
                else
                {
                    m_atomicCounter.Set(amount);
                    m_flags |= MsgFlags.Shared;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// If this Msg is of MsgType.Pool, then - add the given amount number to the reference-counter
        /// and set the shared-data Flags bit.
        /// If this is not a Pool Msg, this does nothing.
        /// </summary>
        /// <param name="amount">the number to add to the internal reference-counter</param>
        public void AddReferences(int amount)
        {
            if (amount == 0)
            {
                return;
            }

            if (MsgType == MsgType.Pool)
            {
                if (IsShared)
                {
                    m_refCount.Increase(amount);
                }
                else
                {
                    m_refCount.Set(amount);
                    Flags |= MsgFlags.Shared;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// If this Msg is of MsgType.Pool, then - add the given amount number to the reference-counter
        /// and set the shared-data Flags bit.
        /// If this is not a Pool Msg, this does nothing.
        /// </summary>
        /// <param name="amount">the number to add to the internal reference-counter</param>
        public void AddReferences(int amount)
        {
            if (amount == 0)
            {
                return;
            }

            if (MsgType == MsgType.Pool)
            {
                if (IsShared)
                {
                    m_refCount.Increase(amount);
                }
                else
                {
                    // Because msg is not yet shared we add 1 to the amount to represent the current copy of the msg.
                    // We can set the amount in a none thread-safe way because the message is not yet shared and
                    // therefore only being used by one thread
                    m_refCount.Set(amount + 1);
                    Flags |= MsgFlags.Shared;
                }
            }
        }