lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [02/38] lucenenet git commit: API: Lucene.Net.Codecs.MultiLevelSkipListReader: implemented proper dispose pattern
Date Thu, 22 Jun 2017 05:25:03 GMT
API: Lucene.Net.Codecs.MultiLevelSkipListReader: implemented proper dispose pattern


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

Branch: refs/heads/master
Commit: 93d80d322b757a870ccc747171588d35df3fdbf1
Parents: 2663003
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Jun 17 12:47:46 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Jun 17 12:47:46 2017 +0700

----------------------------------------------------------------------
 .../Codecs/MultiLevelSkipListReader.cs          | 21 ++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/93d80d32/src/Lucene.Net/Codecs/MultiLevelSkipListReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Codecs/MultiLevelSkipListReader.cs b/src/Lucene.Net/Codecs/MultiLevelSkipListReader.cs
index 63d25f9..078354d 100644
--- a/src/Lucene.Net/Codecs/MultiLevelSkipListReader.cs
+++ b/src/Lucene.Net/Codecs/MultiLevelSkipListReader.cs
@@ -228,13 +228,26 @@ namespace Lucene.Net.Codecs
         /// <summary>
         /// Disposes all resources used by this object.
         /// </summary>
-        public void Dispose() // LUCENENET TODO: API - implement dispose pattern
+        public void Dispose()
         {
-            for (int i = 1; i < skipStream.Length; i++)
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        /// <summary>
+        /// Disposes all resources used by this object. Subclasses may override
+        /// to dispose their own resources.
+        /// </summary>
+        protected virtual void Dispose(bool disposing)
+        {
+            if (disposing)
             {
-                if (skipStream[i] != null)
+                for (int i = 1; i < skipStream.Length; i++)
                 {
-                    skipStream[i].Dispose();
+                    if (skipStream[i] != null)
+                    {
+                        skipStream[i].Dispose();
+                    }
                 }
             }
         }


Mime
View raw message