コード例 #1
0
        /// <summary>
        /// 引用-1
        /// </summary>
        public bool Release(object refer_)
        {
            if (IsDisposed(true))
            {
                return(false);
            }

            if (refer_ != null)
            {
                string referId = Refer.Format(refer_);
                if (!m_refHash.Contains(referId))
                {
                    //没被它引用
                    return(false);
                }
                m_refHash.Remove(referId);
                Refer.DetachDispose(referId, OnReferDispose);
            }

            if (m_ref_cnt > 0)
            {
                m_ref_cnt--;
                if (m_ref_cnt == 0)
                {
                    __OnRelease();
                }
            }
            else
            {
                Log.Assert("错误的引用计数", this);
            }
            return(true);
        }
コード例 #2
0
        void ClearAllRefers()
        {
            m_ref_cnt = 0;

            if (m_refHash.Count > 0)
            {
                foreach (string kvp in m_refHash)
                {
                    Refer.DetachDispose(kvp, OnReferDispose);
                }
                m_refHash.Clear();
            }
        }