blob: 1bc7300235ec4fc8edd7164dd4613f35893011af [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Class ReferenceManager&lt;G&gt;
| Apache Lucene.NET 4.8.0-beta00010 Documentation </title>
<meta name="viewport" content="width=device-width">
<meta name="title" content="Class ReferenceManager&lt;G&gt;
| Apache Lucene.NET 4.8.0-beta00010 Documentation ">
<meta name="generator" content="docfx 2.56.0.0">
<link rel="shortcut icon" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/favicon.ico">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.css">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.css">
<link rel="stylesheet" href="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.css">
<meta property="docfx:navrel" content="toc.html">
<meta property="docfx:tocrel" content="core/toc.html">
<meta property="docfx:rel" content="https://lucenenet.apache.org/docs/4.8.0-beta00009/">
</head>
<body data-spy="scroll" data-target="#affix" data-offset="120">
<div id="wrapper">
<header>
<nav id="autocollapse" class="navbar ng-scope" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img id="logo" class="svg" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/logo/lucene-net-color.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<form class="navbar-form navbar-right" role="search" id="search">
<div class="form-group">
<input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">
</div>
</form>
</div>
</div>
</nav>
<div class="subnav navbar navbar-default">
<div class="container hide-when-search">
<ul class="level0 breadcrumb">
<li>
<a href="https://lucenenet.apache.org/docs/4.8.0-beta00009/">API</a>
<span id="breadcrumb">
<ul class="breadcrumb">
<li></li>
</ul>
</span>
</li>
</ul>
</div>
</div>
</header>
<div class="container body-content">
<div id="search-results">
<div class="search-list"></div>
<div class="sr-items">
<p><i class="glyphicon glyphicon-refresh index-loading"></i></p>
</div>
<ul id="pagination"></ul>
</div>
</div>
<div role="main" class="container body-content hide-when-search">
<div class="sidenav hide-when-search">
<a class="btn toc-toggle collapse" data-toggle="collapse" href="#sidetoggle" aria-expanded="false" aria-controls="sidetoggle">Show / Hide Table of Contents</a>
<div class="sidetoggle collapse" id="sidetoggle">
<div id="sidetoc"></div>
</div>
</div>
<div class="article row grid-right">
<div class="col-md-10">
<article class="content wrap" id="_content" data-uid="Lucene.Net.Search.ReferenceManager`1">
<h1 id="Lucene_Net_Search_ReferenceManager_1" data-uid="Lucene.Net.Search.ReferenceManager`1" class="text-break">Class ReferenceManager&lt;G&gt;
</h1>
<div class="markdown level0 summary"><p>Utility class to safely share instances of a certain type across multiple
threads, while periodically refreshing them. This class ensures each
reference is closed only once all threads have finished using it. It is
recommended to consult the documentation of <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html">ReferenceManager&lt;G&gt;</a>
implementations for their <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_MaybeRefresh">MaybeRefresh()</a> semantics.
<p>
<div class="lucene-block lucene-experimental">This is a Lucene.NET EXPERIMENTAL API, use at your own risk</div></div>
<div class="markdown level0 conceptual"></div>
<div class="inheritance">
<h5>Inheritance</h5>
<div class="level0"><span class="xref">System.Object</span></div>
<div class="level1"><span class="xref">ReferenceManager&lt;G&gt;</span></div>
<div class="level2"><a class="xref" href="Lucene.Net.Index.ReaderManager.html">ReaderManager</a></div>
<div class="level2"><a class="xref" href="Lucene.Net.Search.SearcherManager.html">SearcherManager</a></div>
</div>
<div classs="implements">
<h5>Implements</h5>
<div><span class="xref">System.IDisposable</span></div>
</div>
<div class="inheritedMembers">
<h5>Inherited Members</h5>
<div>
<span class="xref">System.Object.Equals(System.Object)</span>
</div>
<div>
<span class="xref">System.Object.Equals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.GetHashCode()</span>
</div>
<div>
<span class="xref">System.Object.GetType()</span>
</div>
<div>
<span class="xref">System.Object.MemberwiseClone()</span>
</div>
<div>
<span class="xref">System.Object.ReferenceEquals(System.Object, System.Object)</span>
</div>
<div>
<span class="xref">System.Object.ToString()</span>
</div>
</div>
<h6><strong>Namespace</strong>: <a class="xref" href="Lucene.Net.Search.html">Lucene.Net.Search</a></h6>
<h6><strong>Assembly</strong>: Lucene.Net.dll</h6>
<h5 id="Lucene_Net_Search_ReferenceManager_1_syntax">Syntax</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public abstract class ReferenceManager&lt;G&gt; : IDisposable where G : class</code></pre>
</div>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="parametername">G</span></td>
<td><p>The concrete type that will be <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a>d and
<a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Release__0_">Release(G)</a>d.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="properties">Properties
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_Current.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.Current%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L51">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_Current_" data-uid="Lucene.Net.Search.ReferenceManager`1.Current*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_Current" data-uid="Lucene.Net.Search.ReferenceManager`1.Current">Current</h4>
<div class="markdown level1 summary"><p>The current reference</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected G Current { get; set; }</code></pre>
</div>
<h5 class="propertyValue">Property Value</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td></td>
</tr>
</tbody>
</table>
<h3 id="methods">Methods
</h3>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_Acquire.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.Acquire%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L104">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_Acquire_" data-uid="Lucene.Net.Search.ReferenceManager`1.Acquire*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_Acquire" data-uid="Lucene.Net.Search.ReferenceManager`1.Acquire">Acquire()</h4>
<div class="markdown level1 summary"><p>Obtain the current reference. You must match every call to acquire with one
call to <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Release__0_">Release(G)</a>; it&apos;s best to do so in a finally clause, and set
the reference to <code>null</code> to prevent accidental usage after it has been
released. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public G Acquire()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>If the reference manager has been <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>d. </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_AddListener_Lucene_Net_Search_ReferenceManager_IRefreshListener_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.AddListener(Lucene.Net.Search.ReferenceManager.IRefreshListener)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L337">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_AddListener_" data-uid="Lucene.Net.Search.ReferenceManager`1.AddListener*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_AddListener_Lucene_Net_Search_ReferenceManager_IRefreshListener_" data-uid="Lucene.Net.Search.ReferenceManager`1.AddListener(Lucene.Net.Search.ReferenceManager.IRefreshListener)">AddListener(ReferenceManager.IRefreshListener)</h4>
<div class="markdown level1 summary"><p>Adds a listener, to be notified when a reference is refreshed/swapped.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void AddListener(ReferenceManager.IRefreshListener listener)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.ReferenceManager.IRefreshListener.html">ReferenceManager.IRefreshListener</a></td>
<td><span class="parametername">listener</span></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_AfterMaybeRefresh.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.AfterMaybeRefresh%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L303">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_AfterMaybeRefresh_" data-uid="Lucene.Net.Search.ReferenceManager`1.AfterMaybeRefresh*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_AfterMaybeRefresh" data-uid="Lucene.Net.Search.ReferenceManager`1.AfterMaybeRefresh">AfterMaybeRefresh()</h4>
<div class="markdown level1 summary"><p>Called after a refresh was attempted, regardless of
whether a new reference was in fact created. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected virtual void AfterMaybeRefresh()</code></pre>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>if a low level I/O exception occurs</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_DecRef__0_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.DecRef(%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L83">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_DecRef_" data-uid="Lucene.Net.Search.ReferenceManager`1.DecRef*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_DecRef__0_" data-uid="Lucene.Net.Search.ReferenceManager`1.DecRef(`0)">DecRef(G)</h4>
<div class="markdown level1 summary"><p>Decrement reference counting on the given reference. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected abstract void DecRef(G reference)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td><span class="parametername">reference</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>If reference decrement on the given resource failed.</p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_Dispose.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.Dispose%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L155">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_Dispose_" data-uid="Lucene.Net.Search.ReferenceManager`1.Dispose*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_Dispose" data-uid="Lucene.Net.Search.ReferenceManager`1.Dispose">Dispose()</h4>
<div class="markdown level1 summary"><p>
Closes this ReferenceManager to prevent future <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a>ing. A
reference manager should be disposed if the reference to the managed resource
should be disposed or the application using the <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html">ReferenceManager&lt;G&gt;</a>
is shutting down. The managed resource might not be released immediately,
if the <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html">ReferenceManager&lt;G&gt;</a> user is holding on to a previously
<a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a>d reference. The resource will be released once
when the last reference is <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Release__0_">Release(G)</a>d. Those
references can still be used as if the manager was still active.
</p>
<p>
Applications should not <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a> new references from this
manager once this method has been called. <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a>ing a
resource on a disposed <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html">ReferenceManager&lt;G&gt;</a> will throw an
<span class="xref">System.ObjectDisposedException</span>.
</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void Dispose()</code></pre>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>If the underlying reader of the current reference could not be disposed </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_Dispose_System_Boolean_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.Dispose(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L173">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_Dispose_" data-uid="Lucene.Net.Search.ReferenceManager`1.Dispose*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_Dispose_System_Boolean_" data-uid="Lucene.Net.Search.ReferenceManager`1.Dispose(System.Boolean)">Dispose(Boolean)</h4>
<div class="markdown level1 summary"><p>Called after <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>, so subclass can free any resources. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected virtual void Dispose(bool disposing)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td><span class="parametername">disposing</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>if the after dispose operation in a sub-class throws an <span class="xref">System.IO.IOException</span></p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_GetRefCount__0_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.GetRefCount(%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L167">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_GetRefCount_" data-uid="Lucene.Net.Search.ReferenceManager`1.GetRefCount*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_GetRefCount__0_" data-uid="Lucene.Net.Search.ReferenceManager`1.GetRefCount(`0)">GetRefCount(G)</h4>
<div class="markdown level1 summary"><p>Returns the current reference count of the given reference.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected abstract int GetRefCount(G reference)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td><span class="parametername">reference</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Int32</span></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_MaybeRefresh.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.MaybeRefresh%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L250">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_MaybeRefresh_" data-uid="Lucene.Net.Search.ReferenceManager`1.MaybeRefresh*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_MaybeRefresh" data-uid="Lucene.Net.Search.ReferenceManager`1.MaybeRefresh">MaybeRefresh()</h4>
<div class="markdown level1 summary"><p>You must call this (or <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_MaybeRefreshBlocking">MaybeRefreshBlocking()</a>), periodically, if
you want that <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a> will return refreshed instances.</p>
<p>
<strong>Threads</strong>: it&apos;s fine for more than one thread to call this at once.
Only the first thread will attempt the refresh; subsequent threads will see
that another thread is already handling refresh and will return
immediately. Note that this means if another thread is already refreshing
then subsequent threads will return right away without waiting for the
refresh to complete.
</p>
<p>
If this method returns <code>true</code> it means the calling thread either refreshed or
that there were no changes to refresh. If it returns <code>false</code> it means another
thread is currently refreshing.
</p> </div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public bool MaybeRefresh()</code></pre>
</div>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>If refreshing the resource causes an <span class="xref">System.IO.IOException</span> </p>
</td>
</tr>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>If the reference manager has been <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>d. </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_MaybeRefreshBlocking.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.MaybeRefreshBlocking%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L283">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_MaybeRefreshBlocking_" data-uid="Lucene.Net.Search.ReferenceManager`1.MaybeRefreshBlocking*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_MaybeRefreshBlocking" data-uid="Lucene.Net.Search.ReferenceManager`1.MaybeRefreshBlocking">MaybeRefreshBlocking()</h4>
<div class="markdown level1 summary"><p>You must call this (or <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_MaybeRefresh">MaybeRefresh()</a>), periodically, if you want
that <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a> will return refreshed instances.</p>
<p><p>
<strong>Threads</strong>: unlike <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_MaybeRefresh">MaybeRefresh()</a>, if another thread is
currently refreshing, this method blocks until that thread completes. It is
useful if you want to guarantee that the next call to <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a>
will return a refreshed instance. Otherwise, consider using the
non-blocking <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_MaybeRefresh">MaybeRefresh()</a>. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void MaybeRefreshBlocking()</code></pre>
</div>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>If refreshing the resource causes an <span class="xref">System.IO.IOException</span> </p>
</td>
</tr>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>If the reference manager has been <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>d. </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_RefreshIfNeeded__0_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.RefreshIfNeeded(%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L90">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_RefreshIfNeeded_" data-uid="Lucene.Net.Search.ReferenceManager`1.RefreshIfNeeded*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_RefreshIfNeeded__0_" data-uid="Lucene.Net.Search.ReferenceManager`1.RefreshIfNeeded(`0)">RefreshIfNeeded(G)</h4>
<div class="markdown level1 summary"><p>Refresh the given reference if needed. Returns <code>null</code> if no refresh
was needed, otherwise a new refreshed reference. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected abstract G RefreshIfNeeded(G referenceToRefresh)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td><span class="parametername">referenceToRefresh</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>If the reference manager has been <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>d. </p>
</td>
</tr>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>If the refresh operation failed </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_Release__0_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.Release(%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L312">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_Release_" data-uid="Lucene.Net.Search.ReferenceManager`1.Release*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_Release__0_" data-uid="Lucene.Net.Search.ReferenceManager`1.Release(`0)">Release(G)</h4>
<div class="markdown level1 summary"><p>Release the reference previously obtained via <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Acquire">Acquire()</a>.
<p>
<strong>NOTE:</strong> it&apos;s safe to call this after <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public void Release(G reference)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td><span class="parametername">reference</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.IO.IOException</span></td>
<td><p>If the release operation on the given resource throws an <span class="xref">System.IO.IOException</span> </p>
</td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_RemoveListener_Lucene_Net_Search_ReferenceManager_IRefreshListener_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.RemoveListener(Lucene.Net.Search.ReferenceManager.IRefreshListener)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L349">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_RemoveListener_" data-uid="Lucene.Net.Search.ReferenceManager`1.RemoveListener*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_RemoveListener_Lucene_Net_Search_ReferenceManager_IRefreshListener_" data-uid="Lucene.Net.Search.ReferenceManager`1.RemoveListener(Lucene.Net.Search.ReferenceManager.IRefreshListener)">RemoveListener(ReferenceManager.IRefreshListener)</h4>
<div class="markdown level1 summary"><p>Remove a listener added with <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_AddListener_Lucene_Net_Search_ReferenceManager_IRefreshListener_">AddListener(ReferenceManager.IRefreshListener)</a>.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public virtual void RemoveListener(ReferenceManager.IRefreshListener listener)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="Lucene.Net.Search.ReferenceManager.IRefreshListener.html">ReferenceManager.IRefreshListener</a></td>
<td><span class="parametername">listener</span></td>
<td></td>
</tr>
</tbody>
</table>
<span class="small pull-right mobile-hide">
<span class="divider">|</span>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1_TryIncRef__0_.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601.TryIncRef(%600)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/NightOwl888/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L96">View Source</a>
</span>
<a id="Lucene_Net_Search_ReferenceManager_1_TryIncRef_" data-uid="Lucene.Net.Search.ReferenceManager`1.TryIncRef*"></a>
<h4 id="Lucene_Net_Search_ReferenceManager_1_TryIncRef__0_" data-uid="Lucene.Net.Search.ReferenceManager`1.TryIncRef(`0)">TryIncRef(G)</h4>
<div class="markdown level1 summary"><p>Try to increment reference counting on the given reference. Returns <code>true</code> if
the operation was successful. </p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">protected abstract bool TryIncRef(G reference)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">G</span></td>
<td><span class="parametername">reference</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.Boolean</span></td>
<td></td>
</tr>
</tbody>
</table>
<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-striped table-condensed">
<thead>
<tr>
<th>Type</th>
<th>Condition</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="xref">System.ObjectDisposedException</span></td>
<td><p>if the reference manager has been <a class="xref" href="Lucene.Net.Search.ReferenceManager-1.html#Lucene_Net_Search_ReferenceManager_1_Dispose">Dispose()</a>d. </p>
</td>
</tr>
</tbody>
</table>
<h3 id="implements">Implements</h3>
<div>
<span class="xref">System.IDisposable</span>
</div>
<h3 id="extensionmethods">Extension Methods</h3>
<div>
<a class="xref" href="Lucene.Net.Search.ReferenceManagerExtensions.html#Lucene_Net_Search_ReferenceManagerExtensions_GetContext__1_Lucene_Net_Search_ReferenceManager___0__">ReferenceManagerExtensions.GetContext&lt;T&gt;(ReferenceManager&lt;T&gt;)</a>
</div>
</article>
</div>
<div class="hidden-sm col-md-2" role="complementary">
<div class="sideaffix">
<div class="contribution">
<ul class="nav">
<li>
<a href="https://github.com/apache/lucenenet/new/docs/4.8.0-beta00010/websites/apidocs/apiSpec/new?filename=Lucene_Net_Search_ReferenceManager_1.md&amp;value=---%0Auid%3A%20Lucene.Net.Search.ReferenceManager%601%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/apache/lucenenet/blob/release/Lucene.Net_4_8_0_beta00010/src/Lucene.Net/Search/ReferenceManager.cs/#L38" class="contribution-link">View Source</a>
</li>
</ul>
</div>
<nav class="bs-docs-sidebar hidden-print hidden-xs hidden-sm affix" id="affix">
<!-- <p><a class="back-to-top" href="#top">Back to top</a><p> -->
</nav>
</div>
</div>
</div>
</div>
<footer>
<div class="grad-bottom"></div>
<div class="footer">
<div class="container">
<span class="pull-right">
<a href="#top">Back to top</a>
</span>
Copyright © 2020 Licensed to the Apache Software Foundation (ASF)
</div>
</div>
</footer>
</div>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.vendor.js"></script>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/docfx.js"></script>
<script type="text/javascript" src="https://lucenenet.apache.org/docs/4.8.0-beta00009/styles/main.js"></script>
</body>
</html>