Permalink
Browse files

Properly handling disposing of values inside CloseableThreadLocal.cs

  • Loading branch information...
1 parent 7bfc902 commit bd9ca1ab154732d27985c2d237917af8bbd5fbf3 @ayende ayende committed Aug 22, 2011
Binary file not shown.
Binary file not shown.
@@ -1261,6 +1261,12 @@
were cloned from.
</summary>
</member>
+ <member name="M:Lucene.Net.Store.IndexInput.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="F:Lucene.Net.Store.BufferedIndexInput.BUFFER_SIZE">
<summary>Default buffer size </summary>
</member>
@@ -4723,6 +4729,12 @@
<member name="M:Lucene.Net.Analysis.TokenStream.Close">
<summary>Releases resources associated with this stream. </summary>
</member>
+ <member name="M:Lucene.Net.Analysis.TokenStream.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="T:Lucene.Net.Analysis.TokenStream.MethodSupport">
<deprecated> Remove this when old API is removed!
</deprecated>
@@ -6960,6 +6972,12 @@
<deprecated> This will be removed (hardwired to true) in 3.0
</deprecated>
</member>
+ <member name="M:Lucene.Net.Analysis.Standard.StandardAnalyzer.SavedStreams.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="T:Lucene.Net.Analysis.CharReader">
<summary> CharReader is a Reader wrapper. It reads chars from
Reader and outputs {@link CharStream}, defining an
@@ -20130,6 +20148,12 @@
</param>
<throws> IOException </throws>
</member>
+ <member name="M:Lucene.Net.Index.TermVectorsReader.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="T:Lucene.Net.Index.ParallelArrayTermVectorMapper">
<summary> Models the existing parallel array structure</summary>
</member>
@@ -20196,6 +20220,12 @@
<member name="T:Lucene.Net.Index.TermInfosReader.ThreadResources">
<summary> Per-thread resources managed by ThreadLocal</summary>
</member>
+ <member name="M:Lucene.Net.Index.TermInfosReader.ThreadResources.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="M:Lucene.Net.Index.SegmentTermEnum.Next">
<summary>Increments the enumeration to the next element. True if one exists.</summary>
</member>
@@ -21500,6 +21530,12 @@
This will have the most payoff on large fields.
</summary>
</member>
+ <member name="M:Lucene.Net.Index.FieldsReader.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="T:Lucene.Net.Index.FieldsReader.LazyField">
<summary> A Lazy implementation of Fieldable that differs loading of fields until asked for, instead of when the Document is
loaded.
@@ -22681,6 +22717,12 @@
<member name="T:Lucene.Net.Analysis.StopAnalyzer.SavedStreams">
<summary>Filters LowerCaseTokenizer with StopFilter. </summary>
</member>
+ <member name="M:Lucene.Net.Analysis.StopAnalyzer.SavedStreams.Dispose">
+ <summary>
+ Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ </summary>
+ <filterpriority>2</filterpriority>
+ </member>
<member name="T:Lucene.Net.Analysis.CachingTokenFilter">
<summary> This class can be used if the token attributes of a TokenStream
are intended to be consumed more than once. It caches
@@ -325,10 +325,22 @@ public override TokenStream TokenStream(System.String fieldName, System.IO.TextR
return result;
}
- private sealed class SavedStreams
+ private sealed class SavedStreams : IDisposable
{
internal StandardTokenizer tokenStream;
internal TokenStream filteredTokenStream;
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ if(tokenStream!=null)
+ tokenStream.Close();
+ if(filteredTokenStream!=null)
+ filteredTokenStream.Close();
+ }
}
/// <summary>Default maximum allowed token length </summary>
@@ -262,7 +262,7 @@ public override TokenStream TokenStream(System.String fieldName, System.IO.TextR
}
/// <summary>Filters LowerCaseTokenizer with StopFilter. </summary>
- private class SavedStreams
+ private class SavedStreams : IDisposable
{
public SavedStreams(StopAnalyzer enclosingInstance)
{
@@ -283,6 +283,18 @@ public StopAnalyzer Enclosing_Instance
}
internal Tokenizer source;
internal TokenStream result;
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ if(source != null)
+ source.Close();
+ if(result != null)
+ result.Close();
+ }
}
public override TokenStream ReusableTokenStream(System.String fieldName, System.IO.TextReader reader)
@@ -82,7 +82,7 @@ namespace Lucene.Net.Analysis
/// {@link AttributeSource#CaptureState} and {@link AttributeSource#RestoreState}
/// can be used.
/// </summary>
- public abstract class TokenStream:AttributeSource
+ public abstract class TokenStream:AttributeSource, IDisposable
{
private void InitBlock()
{
@@ -501,5 +501,14 @@ public virtual void Reset()
public virtual void Close()
{
}
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ Close();
+ }
}
}
@@ -32,7 +32,7 @@ namespace Lucene.Net.Analysis
/// {@link Token#Clear()} before setting Token attributes.
/// </summary>
- public abstract class Tokenizer:TokenStream
+ public abstract class Tokenizer:TokenStream
{
/// <summary>The text source for this Tokenizer. </summary>
protected internal System.IO.TextReader input;
@@ -36,7 +36,7 @@ namespace Lucene.Net.Index
/// </summary>
/// <version> $Id: FieldsReader.java 801344 2009-08-05 18:05:06Z yonik $
/// </version>
- public sealed class FieldsReader : System.ICloneable
+ public sealed class FieldsReader : System.ICloneable, IDisposable
{
private FieldInfos fieldInfos;
@@ -771,5 +771,14 @@ public FieldForMerge(System.Object value_Renamed, FieldInfo fi, bool binary, boo
this.storeTermVector = fi.storeTermVector;
}
}
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ Close();
+ }
}
}
@@ -48,12 +48,24 @@ sealed class TermInfosReader
private const int DEFAULT_CACHE_SIZE = 1024;
/// <summary> Per-thread resources managed by ThreadLocal</summary>
- private sealed class ThreadResources
+ private sealed class ThreadResources : IDisposable
{
internal SegmentTermEnum termEnum;
// Used for caching the least recently looked-up Terms
internal Lucene.Net.Util.Cache.Cache termInfoCache;
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ if (termEnum != null)
+ termEnum.Close();
+ if (termInfoCache != null)
+ termInfoCache.Close();
+ }
}
internal TermInfosReader(Directory dir, System.String seg, FieldInfos fis, int readBufferSize, int indexDivisor)
@@ -26,7 +26,7 @@ namespace Lucene.Net.Index
/// <version> $Id: TermVectorsReader.java 687046 2008-08-19 13:01:11Z mikemccand $
/// </version>
- public class TermVectorsReader : System.ICloneable
+ public class TermVectorsReader : System.ICloneable, IDisposable
{
// NOTE: if you make a new format, it must be larger than
@@ -647,6 +647,15 @@ public virtual System.Object Clone()
return clone;
}
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
+ /// <filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ Close();
+ }
}
Oops, something went wrong.

0 comments on commit bd9ca1a

Please sign in to comment.