You've already forked linux-packaging-mono
Imported Upstream version 6.4.0.137
Former-commit-id: 943baa9f16a098c33e129777827f3a9d20da00d6
This commit is contained in:
parent
e9207cf623
commit
ef583813eb
@ -0,0 +1,87 @@
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace System.Threading
|
||||
{
|
||||
partial class EventWaitHandle
|
||||
{
|
||||
public bool Set ()
|
||||
{
|
||||
SafeWaitHandle handle = ValidateHandle (out bool release);
|
||||
|
||||
try {
|
||||
return SetEventInternal (handle.DangerousGetHandle ());
|
||||
} finally {
|
||||
if (release)
|
||||
handle.DangerousRelease ();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Reset ()
|
||||
{
|
||||
SafeWaitHandle handle = ValidateHandle (out bool release);
|
||||
|
||||
try {
|
||||
return ResetEventInternal (handle.DangerousGetHandle ());
|
||||
} finally {
|
||||
if (release)
|
||||
handle.DangerousRelease ();
|
||||
}
|
||||
}
|
||||
|
||||
unsafe void CreateEventCore (bool initialState, EventResetMode mode, string name, out bool createdNew)
|
||||
{
|
||||
if (name != null)
|
||||
throw new PlatformNotSupportedException (SR.PlatformNotSupported_NamedSynchronizationPrimitives);
|
||||
|
||||
SafeWaitHandle handle = new SafeWaitHandle (CreateEventInternal (mode == EventResetMode.ManualReset, initialState, null, 0, out int errorCode), ownsHandle: true);
|
||||
if (errorCode != 0)
|
||||
throw new NotImplementedException ("errorCode");
|
||||
SafeWaitHandle = handle;
|
||||
|
||||
createdNew = true;
|
||||
}
|
||||
|
||||
static OpenExistingResult OpenExistingWorker (string name, out EventWaitHandle result)
|
||||
{
|
||||
throw new PlatformNotSupportedException (SR.PlatformNotSupported_NamedSynchronizationPrimitives);
|
||||
}
|
||||
|
||||
internal static bool Set (SafeWaitHandle waitHandle)
|
||||
{
|
||||
bool release = false;
|
||||
try {
|
||||
waitHandle.DangerousAddRef (ref release);
|
||||
return SetEventInternal (waitHandle.DangerousGetHandle ());
|
||||
} finally {
|
||||
if (release)
|
||||
waitHandle.DangerousRelease ();
|
||||
}
|
||||
}
|
||||
|
||||
SafeWaitHandle ValidateHandle (out bool success)
|
||||
{
|
||||
// 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 = SafeWaitHandle;
|
||||
if (waitHandle.IsInvalid)
|
||||
{
|
||||
throw new InvalidOperationException ();
|
||||
}
|
||||
|
||||
success = false;
|
||||
waitHandle.DangerousAddRef (ref success);
|
||||
return waitHandle;
|
||||
}
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
unsafe static extern IntPtr CreateEventInternal (bool manual, bool initialState, char *name, int name_length, out int errorCode);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
static extern bool ResetEventInternal (IntPtr handle);
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
static extern bool SetEventInternal (IntPtr handle);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user