Class BaseDirectory
Base implementation for a concrete Directory.
Note
This API is experimental and might change in incompatible ways in the next release.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Store
Assembly: Lucene.Net.dll
Syntax
public abstract class BaseDirectory : Directory, IDisposable
Constructors
BaseDirectory()
Sole constructor.
Declaration
protected BaseDirectory()
Fields
m_lockFactory
Holds the LockFactory instance (implements locking for this Directory instance).
Declaration
protected LockFactory m_lockFactory
Field Value
Type | Description |
---|---|
LockFactory |
Properties
IsOpen
Gets a value indicating whether the current Directory instance is open.
Expert: This is useful for implementing the EnsureOpen() logic.Declaration
protected virtual bool IsOpen { get; set; }
Property Value
Type | Description |
---|---|
bool |
LockFactory
Get the LockFactory that this Directory instance is using for its locking implementation. Note that this may be null for Directory implementations that provide their own locking implementation.
Declaration
public override LockFactory LockFactory { get; }
Property Value
Type | Description |
---|---|
LockFactory |
Overrides
Methods
ClearLock(string)
Attempt to clear (forcefully unlock and remove) the specified lock. Only call this at a time when you are certain this lock is no longer in use.
Declaration
public override void ClearLock(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | name of the lock to be cleared. |
Overrides
CompareAndSetIsOpen(bool, bool)
Atomically sets the value to the given updated value
if the current value ==
the expected value.
protected override void Dispose(bool disposing)
{
if (!CompareAndSetIsOpen(expect: true, update: false)) return;
// Dispose unmanaged resources
if (disposing)
{
// Dispose managed resources
}
}
Declaration
protected bool CompareAndSetIsOpen(bool expect, bool update)
Parameters
Type | Name | Description |
---|---|---|
bool | expect | The expected value (the comparand). |
bool | update | The new value. |
Returns
Type | Description |
---|---|
bool |
|
EnsureOpen()
Base implementation for a concrete Directory.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
protected override sealed void EnsureOpen()
Overrides
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | if this Directory is closed |
MakeLock(string)
Construct a Lock.
Declaration
public override Lock MakeLock(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | the name of the lock file |
Returns
Type | Description |
---|---|
Lock |
Overrides
SetLockFactory(LockFactory)
Set the LockFactory that this Directory instance should use for its locking implementation. Each * instance of LockFactory should only be used for one directory (ie, do not share a single instance across multiple Directories).
Declaration
public override void SetLockFactory(LockFactory lockFactory)
Parameters
Type | Name | Description |
---|---|---|
LockFactory | lockFactory | instance of LockFactory. |