Lucene.Net.Index.DocumentsWriterStallControl.WaitIfStalled C# (CSharp) Method

WaitIfStalled() public method

Blocks if documents writing is currently in a stalled state.
public WaitIfStalled ( ) : void
return void
        public void WaitIfStalled()
        {
            if (Stalled)
            {
                lock (this)
                {
                    if (Stalled) // react on the first wakeup call!
                    {
                        // don't loop here, higher level logic will re-stall!
                        try
                        {
                            Debug.Assert(IncWaiters());
                            Monitor.Wait(this);
                            Debug.Assert(DecrWaiters());
                        }
                        catch (ThreadInterruptedException e)
                        {
                            throw new ThreadInterruptedException(e);
                        }
                    }
                }
            }
        }

Usage Example

示例#1
0
            public override void Run()
            {
                try
                {
                    while (!stop)
                    {
                        ctrl.WaitIfStalled();
                        if (checkPoint)
                        {
#if FEATURE_THREAD_INTERRUPT
                            try
                            {
#endif
                            Assert.IsTrue(sync.await());
#if FEATURE_THREAD_INTERRUPT
                        }
                        catch (ThreadInterruptedException /*e*/)
                        {
                            Console.WriteLine("[Waiter] got interrupted - wait count: " + sync.waiter.CurrentCount);
                            //throw new ThreadInterruptedException("Thread Interrupted Exception", e);
                            throw;     // LUCENENET: CA2200: Rethrow to preserve stack details (https://docs.microsoft.com/en-us/visualstudio/code-quality/ca2200-rethrow-to-preserve-stack-details)
                        }
#endif
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    Console.Write(e.StackTrace);
                    exceptions.Add(e);
                }
            }
All Usage Examples Of Lucene.Net.Index.DocumentsWriterStallControl::WaitIfStalled