override public void Run()
{
// First time through the while loop we do the merge
// that we were started with:
MergePolicy.OneMerge merge = this.startMerge;
try
{
Enclosing_Instance.Message(" merge thread: start");
while (true)
{
SetRunningMerge(merge);
Enclosing_Instance.DoMerge(merge);
// Subsequent times through the loop we do any new
// merge that writer says is necessary:
merge = writer.GetNextMerge();
if (merge != null)
{
writer.MergeInit(merge);
Enclosing_Instance.Message(" merge thread: do another merge " + merge.SegString(Enclosing_Instance.dir));
}
else
{
break;
}
}
Enclosing_Instance.Message(" merge thread: done");
}
catch (System.Exception exc)
{
// Ignore the exception if it was due to abort:
if (!(exc is MergePolicy.MergeAbortedException))
{
lock (Enclosing_Instance)
{
Enclosing_Instance.exceptions.Add(exc);
}
if (!Enclosing_Instance.suppressExceptions)
{
// suppressExceptions is normally only set during
// testing.
Lucene.Net.Index.ConcurrentMergeScheduler.anyExceptions = true;
Enclosing_Instance.HandleMergeException(exc);
}
}
}
finally
{
lock (Enclosing_Instance)
{
System.Threading.Monitor.PulseAll(Enclosing_Instance);
bool removed = Enclosing_Instance.mergeThreads.Remove(this);
System.Diagnostics.Debug.Assert(removed);
}
}
}