Ejemplo n.º 1
0
 internal void DoOnAbort(ThreadState state)
 {
     lock (this)
     {
         try
         {
             if (state.flushPending)
             {
                 flushBytes -= state.bytesUsed;
             }
             else
             {
                 activeBytes -= state.bytesUsed;
             }
             if (Debugging.AssertsEnabled)
             {
                 Debugging.Assert(AssertMemory());
             }
             // Take it out of the loop this DWPT is stale
             perThreadPool.Reset(state, closed);
         }
         finally
         {
             UpdateStallState();
         }
     }
 }
Ejemplo n.º 2
0
 internal void DoOnAbort(ThreadState state)
 {
     lock (this)
     {
         try
         {
             if (state.flushPending)
             {
                 flushBytes -= state.bytesUsed;
             }
             else
             {
                 activeBytes -= state.bytesUsed;
             }
             if (Debugging.AssertsEnabled)
             {
                 Debugging.Assert(AssertMemory());
             }
             // Take it out of the loop this DWPT is stale
             DocumentsWriterPerThreadPool.Reset(state, closed); // LUCENENET specific - made static per CA1822
         }
         finally
         {
             UpdateStallState();
         }
     }
 }
Ejemplo n.º 3
0
        internal void AddFlushableState(ThreadState perThread)
        {
            if (infoStream.IsEnabled("DWFC"))
            {
                infoStream.Message("DWFC", "addFlushableState " + perThread.dwpt);
            }
            DocumentsWriterPerThread dwpt = perThread.dwpt;

            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(perThread.IsHeldByCurrentThread);
                Debugging.Assert(perThread.IsInitialized);
                Debugging.Assert(fullFlush);
                Debugging.Assert(dwpt.deleteQueue != documentsWriter.deleteQueue);
            }
            if (dwpt.NumDocsInRAM > 0)
            {
                UninterruptableMonitor.Enter(this);
                try
                {
                    if (!perThread.flushPending)
                    {
                        SetFlushPending(perThread);
                    }
                    DocumentsWriterPerThread flushingDWPT = InternalTryCheckOutForFlush(perThread);
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(flushingDWPT != null, "DWPT must never be null here since we hold the lock and it holds documents");
                        Debugging.Assert(dwpt == flushingDWPT, "flushControl returned different DWPT");
                    }
                    fullFlushBuffer.Add(flushingDWPT);
                }
                finally
                {
                    UninterruptableMonitor.Exit(this);
                }
            }
            else
            {
                DocumentsWriterPerThreadPool.Reset(perThread, closed); // make this state inactive // LUCENENET specific - made method static per CA1822
            }
        }
Ejemplo n.º 4
0
 private void CheckoutAndBlock(ThreadState perThread)
 {
     perThread.@Lock();
     try
     {
         if (Debugging.AssertsEnabled)
         {
             Debugging.Assert(perThread.flushPending, "can not block non-pending threadstate");
             Debugging.Assert(fullFlush, "can not block if fullFlush == false");
         }
         DocumentsWriterPerThread dwpt;
         long bytes = perThread.bytesUsed;
         dwpt = DocumentsWriterPerThreadPool.Reset(perThread, closed); // LUCENENET specific - made method static per CA1822
         numPending--;
         blockedFlushes.AddLast(new BlockedFlush(dwpt, bytes));
     }
     finally
     {
         perThread.Unlock();
     }
 }
Ejemplo n.º 5
0
        private DocumentsWriterPerThread InternalTryCheckOutForFlush(ThreadState perThread)
        {
            if (Debugging.AssertsEnabled)
            {
                // LUCENENET specific - Since we need to mimic the unfair behavior of ReentrantLock, we need to ensure that all threads that enter here hold the lock.
                Debugging.Assert(perThread.IsHeldByCurrentThread);
                Debugging.Assert(Monitor.IsEntered(this));
                Debugging.Assert(perThread.flushPending);
            }
            try
            {
                // LUCENENET specific - We removed the call to perThread.TryLock() and the try-finally below as they are no longer needed.

                // We are pending so all memory is already moved to flushBytes
                if (perThread.IsInitialized)
                {
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(perThread.IsHeldByCurrentThread);
                    }
                    DocumentsWriterPerThread dwpt;
                    long bytes = perThread.bytesUsed;                             // do that before
                    // replace!
                    dwpt = DocumentsWriterPerThreadPool.Reset(perThread, closed); // LUCENENET specific - made method static per CA1822
                    if (Debugging.AssertsEnabled)
                    {
                        Debugging.Assert(!flushingWriters.ContainsKey(dwpt), "DWPT is already flushing");
                    }
                    // Record the flushing DWPT to reduce flushBytes in doAfterFlush
                    flushingWriters[dwpt] = bytes;
                    numPending--; // write access synced
                    return(dwpt);
                }
                return(null);
            }
            finally
            {
                UpdateStallState();
            }
        }