Class Epoch
Implements epoch-based reclamation.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public sealed class Epoch
Constructors
View SourceEpoch()
Initializes a new EBR implementation.
Declaration
public Epoch()
Properties
View SourceNativeResourceManager
Gets or sets the manager of the unmanaged resources protected by this epoch.
Declaration
[CLSCompliant(false)]
public Epoch.INativeResourceManager? NativeResourceManager { get; init; }
Property Value
| Type | Description |
|---|---|
| Epoch.INativeResourceManager |
Remarks
The manager is required to defer the release of the unmanaged resources. Epoch uses it to link the deferred resources together, and to release them when they are no longer available to any consumer.
Methods
View SourceClearAsync(CancellationToken)
Clears all the discarded resources safely.
Declaration
public ValueTask ClearAsync(CancellationToken token = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | token | The token that can be used to cancel the operation. |
Returns
| Type | Description |
|---|---|
| ValueTask |
Remarks
If another thread is in its own epoch, the method suspends.
Enter()
Enters the current epoch without the execution of the deferred actions.
Declaration
[MemoryOrdering(MemoryOrdering.SequentiallyConsistent)]
public Epoch.Scope Enter()
Returns
| Type | Description |
|---|---|
| Epoch.Scope | A scope that represents the current epoch. |
Remarks
This method is reentrant. It is recommended to call this method by the reader.
Exceptions
| Type | Condition |
|---|---|
| AggregateException | One or more deferred actions thrown an exception. |
TryClear()
Clears all the discarded resources safely.
Declaration
public bool TryClear()
Returns
| Type | Description |
|---|---|
| bool | true if there is no competing thread entered the epoch, so all epochs are cleaned; otherwise, false and the caller needs to retry. |