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

UpdateStalled() public method

Update the stalled flag status. this method will set the stalled flag to true iff the number of flushing DocumentsWriterPerThread is greater than the number of active DocumentsWriterPerThread. Otherwise it will reset the DocumentsWriterStallControl to healthy and release all threads waiting on #waitIfStalled()
public UpdateStalled ( bool stalled ) : void
stalled bool
return void
        public void UpdateStalled(bool stalled)
        {
            lock (this)
            {
                this.Stalled = stalled;
                if (stalled)
                {
                    WasStalled_Renamed = true;
                }
                Monitor.PulseAll(this);
            }
        }

Usage Example

        public virtual void TestRandom()
        {
            DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();

            ctrl.UpdateStalled(false);

            ThreadClass[] stallThreads = new ThreadClass[AtLeast(3)];
            for (int i = 0; i < stallThreads.Length; i++)
            {
                int stallProbability = 1 + Random().Next(10);
                stallThreads[i] = new ThreadAnonymousInnerClassHelper(this, ctrl, stallProbability);
            }
            Start(stallThreads);
            long time = DateTime.Now.Millisecond;

            /*
             * use a 100 sec timeout to make sure we not hang forever. join will fail in
             * that case
             */
            while ((DateTime.Now.Millisecond - time) < 100 * 1000 && !Terminated(stallThreads))
            {
                ctrl.UpdateStalled(false);
                if (Random().NextBoolean())
                {
                    Thread.@Yield();
                }
                else
                {
                    Thread.Sleep(1);
                }
            }
            Join(stallThreads);
        }
All Usage Examples Of Lucene.Net.Index.DocumentsWriterStallControl::UpdateStalled