Show / Hide Table of Contents

Class Epoch

Implements epoch-based reclamation.

Inheritance
object
Epoch
Inherited Members
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public sealed class Epoch

Constructors

View Source

Epoch()

Initializes a new EBR implementation.

Declaration
public Epoch()

Properties

View Source

NativeResourceManager

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 Source

ClearAsync(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.

View Source

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.

View Source

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.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, params ReadOnlySpan<T>)

See Also

Practical lock-freedom
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾