コード例 #1
0
        public bool Contains(LockFreeNode node)
        {
            if (node == null)
            {
                return false;
            }

            LockFreeListWindow window = Find(node);

            if(window == null)
            {
                return false;
            }

            if (window.Current.IsLogicallyRemoved)
            {
                return false;
            }

            return true;
        }
コード例 #2
0
        public void Remove(LockFreeNode node)
        {
            if(node == null)
            {
                return;
            }

            while(true)
            {
                LockFreeListWindow window = Find(node);

                if(window == null)
                {
                    return;
                }

                window.Current.IsLogicallyRemoved = true;

                if(window.Previous == null)
                {
                    if(Interlocked.CompareExchange(ref head, window.Current.GetNext(), window.Current) == window.Current)
                    {
                        return;
                    }
                }
                else
                {
                    if(window.Previous.IsLogicallyRemoved)
                    {
                        continue;
                    }

                    if (Interlocked.CompareExchange(ref window.Previous.GetRefNext(), window.Current.GetNext(), window.Current) == window.Current)
                    {
                        return;
                    }
                }
            }
        }