Show / Hide Table of Contents

Class Epoch

Implements epoch-based reclamation.

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

Methods

| Edit this page View Source

Enter(bool, out RecycleBin)

Enters the current epoch, but doesn't execute any deferred actions.

Declaration
public Epoch.Scope Enter(bool drainGlobalCache, out Epoch.RecycleBin bin)
Parameters
Type Name Description
bool drainGlobalCache

true to capture all deferred actions across all threads; false to capture actions that were deferred by the current thread at some point in the past.

Epoch.RecycleBin bin

An action that can be called at any point in time to invoke deferred actions.

Returns
Type Description
Epoch.Scope

A scope that represents the current epoch.

Remarks

This method is reentrant and never throws an exception.

| Edit this page View Source

Enter(bool, out Scope)

Enters the current epoch, and optionally executes a deferred actions.

Declaration
public void Enter(bool drainGlobalCache, out Epoch.Scope scope)
Parameters
Type Name Description
bool drainGlobalCache

true to capture all deferred actions across all threads; false to capture actions that were deferred by the current thread at some point in the past.

Epoch.Scope scope

The protection scope. It is initialized in case of exceptions raised by the deferred actions invoked by the method.

Remarks

This method is reentrant. In case of exceptions in one or more deferred actions the aggregated exception is propagated to the caller. In this case, the caller is responsible to close the scope correctly.

Exceptions
Type Condition
AggregateException

One or more deferred actions thrown an exception.

| Edit this page View Source

Enter(bool?)

Enters the current epoch, and optionally executes a deferred actions.

Declaration
public Epoch.Scope Enter(bool? drainGlobalCache = false)
Parameters
Type Name Description
bool? drainGlobalCache

null to avoid reclamation; true to capture all deferred actions across all threads; false to capture actions that were deferred by the current thread at some point in the past.

Returns
Type Description
Epoch.Scope

A scope that represents the current epoch.

Remarks

This method is reentrant. In case of exceptions in one or more deferred actions the method closes the scope correctly.

Exceptions
Type Condition
AggregateException

One or more deferred actions thrown an exception.

| Edit this page View Source

UnsafeClear()

Invokes all deferred actions across all epochs.

Declaration
public void UnsafeClear()
Remarks

This method is not thread-safe and cannot be called concurrently with other threads entered a protected region with Enter(bool?). The caller must ensure that all threads finished their work prior to this method.

Exceptions
Type Condition
InvalidOperationException

Not all threads relying on the current instance finished their work.

AggregateException

One or more deferred actions throw an exception.

| Edit this page View Source

UnsafeEnter(bool)

Enters the current epoch, and optionally executes a deferred actions.

Declaration
public Epoch.Scope UnsafeEnter(bool drainGlobalCache = false)
Parameters
Type Name Description
bool drainGlobalCache

true to capture all deferred actions across all threads; false to capture actions that were deferred by the current thread at some point in the past.

Returns
Type Description
Epoch.Scope
Remarks

This method is reentrant. In case of exceptions in one or more deferred actions the aggregated exception is propagated to the caller. There is no way for the caller to close the scope correctly.

Exceptions
Type Condition
AggregateException

One or more deferred actions thrown an exception.

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)

See Also

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