コード例 #1
0
 internal DocumentsWriterPerThread DoAfterDocument(ThreadState perThread, bool isUpdate)
 {
     UninterruptableMonitor.Enter(this);
     try
     {
         try
         {
             CommitPerThreadBytes(perThread);
             if (!perThread.flushPending)
             {
                 if (isUpdate)
                 {
                     flushPolicy.OnUpdate(this, perThread);
                 }
                 else
                 {
                     flushPolicy.OnInsert(this, perThread);
                 }
                 if (!perThread.flushPending && perThread.bytesUsed > hardMaxBytesPerDWPT)
                 {
                     // Safety check to prevent a single DWPT exceeding its RAM limit. this
                     // is super important since we can not address more than 2048 MB per DWPT
                     SetFlushPending(perThread);
                 }
             }
             DocumentsWriterPerThread flushingDWPT;
             if (fullFlush)
             {
                 if (perThread.flushPending)
                 {
                     CheckoutAndBlock(perThread);
                     flushingDWPT = NextPendingFlush();
                 }
                 else
                 {
                     flushingDWPT = null;
                 }
             }
             else
             {
                 flushingDWPT = TryCheckoutForFlush(perThread);
             }
             return(flushingDWPT);
         }
         finally
         {
             bool stalled = UpdateStallState();
             if (Debugging.AssertsEnabled)
             {
                 Debugging.Assert(AssertNumDocsSinceStalled(stalled) && AssertMemory());
             }
         }
     }
     finally
     {
         UninterruptableMonitor.Exit(this);
     }
 }
コード例 #2
0
 internal DocumentsWriterPerThread DoAfterDocument(ThreadState perThread, bool isUpdate)
 {
     lock (this)
     {
         try
         {
             CommitPerThreadBytes(perThread);
             if (!perThread.FlushPending_Renamed)
             {
                 if (isUpdate)
                 {
                     FlushPolicy.OnUpdate(this, perThread);
                 }
                 else
                 {
                     FlushPolicy.OnInsert(this, perThread);
                 }
                 if (!perThread.FlushPending_Renamed && perThread.BytesUsed > HardMaxBytesPerDWPT)
                 {
                     // Safety check to prevent a single DWPT exceeding its RAM limit. this
                     // is super important since we can not address more than 2048 MB per DWPT
                     FlushPending = perThread;
                 }
             }
             DocumentsWriterPerThread flushingDWPT;
             if (FullFlush_Renamed)
             {
                 if (perThread.FlushPending_Renamed)
                 {
                     CheckoutAndBlock(perThread);
                     flushingDWPT = NextPendingFlush();
                 }
                 else
                 {
                     flushingDWPT = null;
                 }
             }
             else
             {
                 flushingDWPT = TryCheckoutForFlush(perThread);
             }
             return(flushingDWPT);
         }
         finally
         {
             bool stalled = UpdateStallState();
             Debug.Assert(AssertNumDocsSinceStalled(stalled) && AssertMemory());
         }
     }
 }