Lucene.Net.Core.Search (ControlledRealTimeReopenThread + ReferenceManager): Reviewed code and fixed some minor bugs and formatting issues
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/acc553e9 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/acc553e9 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/acc553e9 Branch: refs/heads/api-work Commit: acc553e9f9e7c5e2f47f3f4c1b64e2304b843bf6 Parents: 3c1f50b Author: Shad Storhaug <[email protected]> Authored: Wed Mar 22 09:05:35 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Wed Mar 22 09:05:35 2017 +0700 ---------------------------------------------------------------------- .../Search/ControlledRealTimeReopenThread.cs | 10 +++++----- src/Lucene.Net.Core/Search/ReferenceManager.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/acc553e9/src/Lucene.Net.Core/Search/ControlledRealTimeReopenThread.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Search/ControlledRealTimeReopenThread.cs b/src/Lucene.Net.Core/Search/ControlledRealTimeReopenThread.cs index de15a75..088205c 100644 --- a/src/Lucene.Net.Core/Search/ControlledRealTimeReopenThread.cs +++ b/src/Lucene.Net.Core/Search/ControlledRealTimeReopenThread.cs @@ -138,7 +138,7 @@ namespace Lucene.Net.Search } catch (ThreadInterruptedException ie) { - throw new ThreadInterruptedException("Thread Interrupted Exception", ie); + throw new ThreadInterruptedException(ie.ToString(), ie); } #endif // Max it out so any waiting search threads will return: @@ -239,7 +239,7 @@ namespace Lucene.Net.Search { // TODO: maybe use private thread ticktock timer, in // case clock shift messes up nanoTime? - long lastReopenStartNS = DateTime.Now.Ticks * 100; + long lastReopenStartNS = Environment.TickCount * 1000000; //System.out.println("reopen: start"); while (!finish) @@ -261,11 +261,11 @@ namespace Lucene.Net.Search bool hasWaiting = waitingGen > searchingGen; long nextReopenStartNS = lastReopenStartNS + (hasWaiting ? targetMinStaleNS : targetMaxStaleNS); - long sleepNS = nextReopenStartNS - (DateTime.Now.Ticks * 100); + long sleepNS = nextReopenStartNS - (Environment.TickCount * 1000000); if (sleepNS > 0) { - reopenCond.WaitOne(new TimeSpan(sleepNS / 100));//Convert NS to Ticks + reopenCond.WaitOne(new TimeSpan(sleepNS / 1000000));//Convert NS to Ticks } else { @@ -293,7 +293,7 @@ namespace Lucene.Net.Search break; } - lastReopenStartNS = DateTime.Now.Ticks * 100; + lastReopenStartNS = Environment.TickCount * 1000000; // Save the gen as of when we started the reopen; the // listener (HandleRefresh above) copies this to // searchingGen once the reopen completes: http://git-wip-us.apache.org/repos/asf/lucenenet/blob/acc553e9/src/Lucene.Net.Core/Search/ReferenceManager.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Core/Search/ReferenceManager.cs b/src/Lucene.Net.Core/Search/ReferenceManager.cs index 78fadce..0d1bf37 100644 --- a/src/Lucene.Net.Core/Search/ReferenceManager.cs +++ b/src/Lucene.Net.Core/Search/ReferenceManager.cs @@ -174,7 +174,7 @@ namespace Lucene.Net.Search /// Called after close(), so subclass can free any resources. </summary> /// <exception cref="IOException"> if the after close operation in a sub-class throws an <seealso cref="IOException"/> /// </exception> - protected internal virtual void AfterClose() + protected virtual void AfterClose() { } @@ -336,7 +336,7 @@ namespace Lucene.Net.Search { if (listener == null) { - throw new System.NullReferenceException("Listener cannot be null"); + throw new System.NullReferenceException("Listener cannot be null"); // LUCENENET TODO: ArgumentNullException ? } refreshListeners.Add(listener); } @@ -348,7 +348,7 @@ namespace Lucene.Net.Search { if (listener == null) { - throw new System.NullReferenceException("Listener cannot be null"); + throw new System.NullReferenceException("Listener cannot be null"); // LUCENENET TODO: ArgumentNullException ? } refreshListeners.Remove(listener); }
