Class Epoch
Implements epoch-based reclamation.
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public class Epoch
Methods
| Edit this page View SourceEnter(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.
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. |
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. |
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. |
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. |