Struct Epoch.Scope
Represents a scope of the region of code protected by the epoch.
Implements
Inherited Members
Namespace: DotNext.Threading
Assembly: DotNext.dll
Syntax
public readonly struct Epoch.Scope : IDisposable
Methods
View SourceDefer(Action)
Registers user action to be called at some point in future when the resource protected by the epoch is no longer available to any consumer.
Declaration
public void Defer(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The callback to enqueue. |
Remarks
Invocation order of callbacks is not guaranteed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
Defer<TWorkItem>(TWorkItem)
Registers user action to be called at some point in future when the resource protected by the epoch is no longer available to any consumer.
Declaration
public void Defer<TWorkItem>(TWorkItem workItem) where TWorkItem : struct, IThreadPoolWorkItem
Parameters
| Type | Name | Description |
|---|---|---|
| TWorkItem | workItem | The callback to enqueue. |
Type Parameters
| Name | Description |
|---|---|
| TWorkItem | The type of the callback. |
Defer<T>(T, Action<T>)
Registers user action to be called at some point in future when the resource protected by the epoch is no longer available to any consumer.
Declaration
public void Defer<T>(T arg, Action<T> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| T | arg | The argument to be passed to the callback. |
| Action<T> | callback | The callback to enqueue. |
Type Parameters
| Name | Description |
|---|---|
| T |
Remarks
Invocation order of callbacks is not guaranteed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
Dispose()
Releases epoch scope.
Declaration
public void Dispose()
Remarks
This method is not idempotent and should not be called twice.
Reclaim(bool)
Reclaims the deferred actions.
Declaration
public Epoch.RecycleBin Reclaim(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.RecycleBin | A collection of reclaimed actions that can be executed at any point in time. |
RegisterForDiscard(Discardable)
Registers an object to be disposed at some point in future when the resource protected by the epoch is no longer available to any consumer.
Declaration
public void RegisterForDiscard(Epoch.Discardable discardable)
Parameters
| Type | Name | Description |
|---|---|---|
| Epoch.Discardable | discardable | An object to be disposed. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
RegisterForDispose(IDisposable)
Registers an object to be disposed at some point in future when the resource protected by the epoch is no longer available to any consumer.
Declaration
public void RegisterForDispose(IDisposable disposable)
Parameters
| Type | Name | Description |
|---|---|---|
| IDisposable | disposable | An object to be disposed. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|