diff options
Diffstat (limited to 'src/System.Private.CoreLib/src/System/Threading/Mutex.cs')
-rw-r--r-- | src/System.Private.CoreLib/src/System/Threading/Mutex.cs | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/src/System.Private.CoreLib/src/System/Threading/Mutex.cs b/src/System.Private.CoreLib/src/System/Threading/Mutex.cs deleted file mode 100644 index 6db36cb59..000000000 --- a/src/System.Private.CoreLib/src/System/Threading/Mutex.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -/*============================================================================= -** -** -** -** Purpose: synchronization primitive that can also be used for interprocess synchronization -** -** -=============================================================================*/ - -using System; -using System.Threading; -using System.Runtime.CompilerServices; -using System.IO; -using Microsoft.Win32; -using Microsoft.Win32.SafeHandles; -using System.Runtime.InteropServices; -using System.Runtime.Versioning; -using System.Security; - -namespace System.Threading -{ - public sealed partial class Mutex : WaitHandle - { - public Mutex(bool initiallyOwned, string name, out bool createdNew) - { - VerifyNameForCreate(name); - - CreateMutexCore(initiallyOwned, name, out createdNew); - } - - public Mutex(bool initiallyOwned, string name) - { - VerifyNameForCreate(name); - - bool createdNew; - CreateMutexCore(initiallyOwned, name, out createdNew); - } - - public Mutex(bool initiallyOwned) - { - bool createdNew; - CreateMutexCore(initiallyOwned, null, out createdNew); - } - - public Mutex() - { - bool createdNew; - CreateMutexCore(false, null, out createdNew); - } - - private Mutex(SafeWaitHandle handle) - { - SafeWaitHandle = handle; - } - - public static Mutex OpenExisting(string name) - { - Mutex result; - switch (OpenExistingWorker(name, out result)) - { - case OpenExistingResult.NameNotFound: - throw new WaitHandleCannotBeOpenedException(); - - case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - - case OpenExistingResult.PathNotFound: - throw new IOException(SR.Format(SR.IO_PathNotFound_Path, name)); - - default: - return result; - } - } - - public static bool TryOpenExisting(string name, out Mutex result) => - OpenExistingWorker(name, out result) == OpenExistingResult.Success; - - public void ReleaseMutex() - { - // The field value is modifiable via the public <see cref="WaitHandle.SafeWaitHandle"/> property, save it locally - // to ensure that one instance is used in all places in this method - SafeWaitHandle waitHandle = _waitHandle; - if (waitHandle == null) - { - ThrowInvalidHandleException(); - } - - waitHandle.DangerousAddRef(); - try - { - ReleaseMutexCore(waitHandle.DangerousGetHandle()); - } - finally - { - waitHandle.DangerousRelease(); - } - } - } -} |