Class DisposeByRefObject
Manages object lifetime by refence counting.
Inherited Members
Namespace: Solti.Utils.Primitives.Patterns
Assembly: Solti.Utils.Primitives.dll
Syntax
public class DisposeByRefObject : Disposable, IDisposableEx
Constructors
DisposeByRefObject()
Declaration
public DisposeByRefObject()
Properties
RefCount
The current reference count.
Declaration
public int RefCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
AddRef()
Increments the reference counter as an atomic operation.
Declaration
public int AddRef()
Returns
Type | Description |
---|---|
System.Int32 | The current reference count. |
AsyncDispose()
Performs application-defined tasks associated with freeing, releasing, or resetting resources asynchronously
Declaration
protected override ValueTask AsyncDispose()
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask |
Overrides
Dispose(Boolean)
Method to be overridden to implement custom disposal logic.
Declaration
protected override void Dispose(bool disposeManaged)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposeManaged | It is set to true on System.IDisposable.Dispose call. |
Overrides
Release()
Decrements the reference counter as an atomic operation and disposes the object if the reference count reached the zero.
Declaration
public int Release()
Returns
Type | Description |
---|---|
System.Int32 | The current reference count. |
ReleaseAsync()
Decrements the reference counter as an atomic operation and disposes the object asynchronously if the reference count reached the zero.
Declaration
public Task<int> ReleaseAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | The current reference count. |
Implements
System.IDisposable
System.IAsyncDisposable