2using System.Threading.Tasks;
12 where TWrapped : class
30 return Task.CompletedTask;
57 Instance = instance ??
throw new ArgumentNullException(nameof(instance));
75 var reference =
new TReference();
Class used for counting references with ReferenceCountingContainer<TWrapped, TReference>.
Wrapper for managing some TWrapped .
TaskCompletionSource? onZeroReferencesTcs
Backing TaskCompletionSource for OnZeroReferences.
TReference AddReference()
Create a new TReference to the Instance.
ulong referenceCount
Count of active Instances.
TWrapped Instance
The TWrapped .
ReferenceCountingContainer(TWrapped instance)
Initializes a new instance of the ReferenceCountingContainer<TWrapped, TReference> class.
Task OnZeroReferences
A Task that completes when there are no TReference s active for the Instance.
readonly object referenceCountLock
lock object for referenceCount.