aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/DisposableIpcService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/DisposableIpcService.cs')
-rw-r--r--src/Ryujinx.HLE/HOS/Services/DisposableIpcService.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/DisposableIpcService.cs b/src/Ryujinx.HLE/HOS/Services/DisposableIpcService.cs
new file mode 100644
index 00000000..2d0802a7
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Services/DisposableIpcService.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Threading;
+
+namespace Ryujinx.HLE.HOS.Services
+{
+ abstract class DisposableIpcService : IpcService, IDisposable
+ {
+ private int _disposeState;
+
+ public DisposableIpcService(ServerBase server = null) : base(server) { }
+
+ protected abstract void Dispose(bool isDisposing);
+
+ public void Dispose()
+ {
+ if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
+ {
+ Dispose(true);
+ }
+ }
+ }
+}