Lucene.Net.Index.DocumentsWriterDeleteQueue.Add C# (CSharp) Method

Add() private method

private Add ( Node item ) : void
item Node
return void
        private void Add(Node item)
        {
            /*
             * this non-blocking / 'wait-free' linked list add was inspired by Apache
             * Harmony's ConcurrentLinkedQueue Implementation.
             */
            while (true)
            {
                Node currentTail = this.Tail;
                Node tailNext = currentTail.Next;
                if (Tail == currentTail)
                {
                    if (tailNext != null)
                    {
                        /*
                         * we are in intermediate state here. the tails next pointer has been
                         * advanced but the tail itself might not be updated yet. help to
                         * advance the tail and try again updating it.
                         */
                        Interlocked.CompareExchange(ref Tail, tailNext, currentTail); // can fail
                    }
                    else
                    {
                        /*
                         * we are in quiescent state and can try to insert the item to the
                         * current tail if we fail to insert we just retry the operation since
                         * somebody else has already added its item
                         */
                        if (currentTail.CasNext(null, item))
                        {
                            /*
                             * now that we are done we need to advance the tail while another
                             * thread could have advanced it already so we can ignore the return
                             * type of this CAS call
                             */
                            Interlocked.CompareExchange(ref Tail, item, currentTail);
                            return;
                        }
                    }
                }
            }
        }

Same methods

DocumentsWriterDeleteQueue::Add ( Lucene.Net.Index.Term term, DeleteSlice slice ) : void

Usage Example

Beispiel #1
0
            public override void Run()
            {
//#if !NETSTANDARD1_6
//                try
//                {
//#endif
                Latch.Wait();
//#if !NETSTANDARD1_6
//                }
//                catch (ThreadInterruptedException e) // LUCENENET NOTE: Senseless to catch and rethrow the same exception type
//                {
//                    throw new ThreadInterruptedException("Thread Interrupted Exception", e);
//                }
//#endif

                int i = 0;

                while ((i = Index.GetAndIncrement()) < Ids.Length)
                {
                    Term term = new Term("id", Ids[i].ToString());
                    Queue.Add(term, Slice);
                    Assert.IsTrue(Slice.IsTailItem(term));
                    Slice.Apply(Deletes, BufferedUpdates.MAX_INT32);
                }
            }
All Usage Examples Of Lucene.Net.Index.DocumentsWriterDeleteQueue::Add