tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DisposeInvoker.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3
5{
10 {
14 public bool IsDisposed => disposeRan != 0;
15
19 readonly Action disposeAction;
20
24 volatile int disposeRan;
25
31 {
32 this.disposeAction = disposeAction ?? throw new ArgumentNullException(nameof(disposeAction));
33 }
34
36 public void Dispose()
37 {
38 if (Interlocked.Exchange(ref disposeRan, 1) != 0)
39 return;
40
42 }
43
47 protected virtual void DisposeImpl() => disposeAction();
48 }
49}
Runs a given disposeAction on Dispose.
readonly Action disposeAction
The Action to run on Dispose.
volatile int disposeRan
An int representation of a bool indicating if Dispose has ran.
virtual void DisposeImpl()
Implementation of Dispose run after reentrancy check.
DisposeInvoker(Action disposeAction)
Initializes a new instance of the DisposeInvoker class.