lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [10/20] lucenenet git commit: Lucene.Net.Core.Index.MergePolicy: implemented .NET dispose pattern
Date Sun, 02 Apr 2017 07:06:10 GMT
Lucene.Net.Core.Index.MergePolicy: implemented .NET dispose pattern


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/2ea33f79
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/2ea33f79
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/2ea33f79

Branch: refs/heads/api-work
Commit: 2ea33f799b331b02d3a9f4b668af13e519a9bf30
Parents: de5e562
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sun Apr 2 10:58:55 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sun Apr 2 11:58:34 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Core/Index/LogMergePolicy.cs             |  2 +-
 src/Lucene.Net.Core/Index/MergePolicy.cs                | 12 +++++++++++-
 src/Lucene.Net.Core/Index/NoMergePolicy.cs              |  2 +-
 src/Lucene.Net.Core/Index/TieredMergePolicy.cs          |  2 +-
 src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs    |  7 +++++--
 src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs  |  7 +++++--
 .../Index/MockRandomMergePolicy.cs                      |  2 +-
 src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs     |  2 +-
 8 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Core/Index/LogMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/LogMergePolicy.cs b/src/Lucene.Net.Core/Index/LogMergePolicy.cs
index 28edd06..4c2b3ab 100644
--- a/src/Lucene.Net.Core/Index/LogMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/LogMergePolicy.cs
@@ -189,7 +189,7 @@ namespace Lucene.Net.Index
             }
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Core/Index/MergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/MergePolicy.cs b/src/Lucene.Net.Core/Index/MergePolicy.cs
index c8731d4..72e2d68 100644
--- a/src/Lucene.Net.Core/Index/MergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/MergePolicy.cs
@@ -691,7 +691,17 @@ namespace Lucene.Net.Index
         /// <summary>
         /// Release all resources for the policy.
         /// </summary>
-        public abstract void Dispose();
+        // LUCENENET specific - implementing proper dispose pattern
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Release all resources for the policy.
+        /// </summary>
+        protected abstract void Dispose(bool disposing);
 
         /// <summary>
         /// Returns true if a new segment (regardless of its origin) should use the

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Core/Index/NoMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/NoMergePolicy.cs b/src/Lucene.Net.Core/Index/NoMergePolicy.cs
index 9426106..beb702c 100644
--- a/src/Lucene.Net.Core/Index/NoMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/NoMergePolicy.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Index
             this.useCompoundFile = useCompoundFile;
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/TieredMergePolicy.cs b/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
index 8a16f05..f41f6c6 100644
--- a/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/TieredMergePolicy.cs
@@ -742,7 +742,7 @@ namespace Lucene.Net.Index
             return spec;
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs b/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
index 8ce1311..d536b5e 100644
--- a/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
+++ b/src/Lucene.Net.Core/Index/UpgradeIndexMergePolicy.cs
@@ -160,9 +160,12 @@ namespace Lucene.Net.Index
             return m_base.UseCompoundFile(segments, newSegment);
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
-            m_base.Dispose();
+            if (disposing)
+            { 
+                m_base.Dispose();
+            }
         }
 
         public override string ToString()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs b/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
index 5249248..773e804 100644
--- a/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
+++ b/src/Lucene.Net.Misc/Index/Sorter/SortingMergePolicy.cs
@@ -258,9 +258,12 @@ namespace Lucene.Net.Index.Sorter
             return new SortingMergePolicy((MergePolicy)@in.Clone(), sort);
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
-            @in.Dispose();
+            if (disposing)
+            {
+                @in.Dispose();
+            }
         }
 
         public override bool UseCompoundFile(SegmentInfos segments, SegmentCommitInfo newSegment)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs b/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
index 820bd3e..b78fa5f 100644
--- a/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
+++ b/src/Lucene.Net.TestFramework/Index/MockRandomMergePolicy.cs
@@ -119,7 +119,7 @@ namespace Lucene.Net.Index
             return FindMerges((MergeTrigger)int.MinValue, segmentInfos);
         }
 
-        public override void Dispose()
+        protected override void Dispose(bool disposing)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/2ea33f79/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs b/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
index 5855138..0ae4569 100644
--- a/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
+++ b/src/Lucene.Net.Tests/Index/TestPerSegmentDeletes.cs
@@ -282,7 +282,7 @@ namespace Lucene.Net.Index
                 this.UseCompoundFile_Renamed = useCompoundFile;
             }
 
-            public override void Dispose()
+            protected override void Dispose(bool disposing)
             {
             }
 


Mime
View raw message