mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-15 17:10:51 -10:00
[corlib] Import System.Threading.WaitHandle
This commit is contained in:
1 parent
98f96e9559
commit
f6fa8f0359
12 files changed
+93
-420
No files matched your search
Vendored
+1
-1
Submodule external/referencesource updated: bf43bae316...423e8998d5.
@@ -3620,12 +3620,15 @@ public class DebuggerTests
|
||||
Assert.AreEqual (ThreadState.WaitSleepJoin, thread.ThreadState, "#6");
|
||||
|
||||
frames = thread.GetFrames ();
|
||||
Assert.AreEqual (4, frames.Length, "#7");
|
||||
Assert.AreEqual ("WaitOne_internal", frames [0].Method.Name, "#8");
|
||||
Assert.AreEqual ("WaitOne", frames [1].Method.Name, "#8.1");
|
||||
Assert.AreEqual ("wait_one", frames [2].Method.Name, "#9");
|
||||
Assert.AreEqual ("Main", frames [3].Method.Name, "#10");
|
||||
|
||||
Assert.AreEqual (8, frames.Length, "#7");
|
||||
Assert.AreEqual ("WaitOne_internal", frames [0].Method.Name, "#8.0");
|
||||
Assert.AreEqual ("WaitOneNative", frames [1].Method.Name, "#8.1");
|
||||
Assert.AreEqual ("InternalWaitOne", frames [2].Method.Name, "#8.2");
|
||||
Assert.AreEqual ("WaitOne", frames [3].Method.Name, "#8.3");
|
||||
Assert.AreEqual ("WaitOne", frames [4].Method.Name, "#8.4");
|
||||
Assert.AreEqual ("WaitOne", frames [5].Method.Name, "#8.5");
|
||||
Assert.AreEqual ("wait_one", frames [6].Method.Name, "#8.6");
|
||||
Assert.AreEqual ("Main", frames [7].Method.Name, "#8.7");
|
||||
|
||||
var frame = frames [0];
|
||||
Assert.IsTrue (frame.IsNativeTransition, "#11.1");
|
||||
@@ -3634,12 +3637,12 @@ public class DebuggerTests
|
||||
Assert.Fail ("Known limitation - can't get info from m2n frames");
|
||||
} catch (AbsentInformationException) {}
|
||||
|
||||
frame = frames [1];
|
||||
frame = frames [3];
|
||||
Assert.IsFalse (frame.IsNativeTransition, "#12.1");
|
||||
var wait_one_this = frame.GetThis ();
|
||||
Assert.IsNotNull (wait_one_this, "#12.2");
|
||||
|
||||
frame = frames [2];
|
||||
frame = frames [6];
|
||||
var locals = frame.GetVisibleVariables ();
|
||||
Assert.AreEqual (1, locals.Count, "#13.1");
|
||||
|
||||
|
||||
@@ -207,6 +207,20 @@ namespace System.Threading
|
||||
return (NativeEventCalls.SetEvent_internal (Handle));
|
||||
}
|
||||
}
|
||||
|
||||
internal void CheckDisposed ()
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException (GetType ().FullName);
|
||||
}
|
||||
|
||||
bool disposed;
|
||||
protected override void Dispose(bool explicitDisposing)
|
||||
{
|
||||
base.Dispose (explicitDisposing);
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
#if !NET_2_1
|
||||
public void SetAccessControl (EventWaitHandleSecurity eventSecurity)
|
||||
{
|
||||
|
||||
@@ -39,404 +39,83 @@ using System.Runtime.ConstrainedExecution;
|
||||
|
||||
namespace System.Threading
|
||||
{
|
||||
[ComVisible (true)]
|
||||
[StructLayout (LayoutKind.Sequential)]
|
||||
public abstract class WaitHandle
|
||||
public abstract partial class WaitHandle
|
||||
: MarshalByRefObject, IDisposable
|
||||
{
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private static extern bool WaitAll_internal(WaitHandle[] handles, int ms, bool exitContext);
|
||||
|
||||
static void CheckArray (WaitHandle [] handles, bool waitAll)
|
||||
protected static readonly IntPtr InvalidHandle = (IntPtr) (-1);
|
||||
|
||||
static int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll)
|
||||
{
|
||||
if (handles == null)
|
||||
throw new ArgumentNullException ("waitHandles");
|
||||
#if MONOTOUCH
|
||||
if (exitContext)
|
||||
throw new NotSupportedException ("exitContext == true is not supported");
|
||||
#endif
|
||||
|
||||
int length = handles.Length;
|
||||
if (length > 64)
|
||||
throw new NotSupportedException ("Too many handles");
|
||||
try {
|
||||
if (exitContext)
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
|
||||
if (handles.Length == 0) {
|
||||
// MS throws different exceptions from the different methods.
|
||||
if (waitAll)
|
||||
throw new ArgumentNullException ("waitHandles");
|
||||
if (WaitAll)
|
||||
return WaitAll_internal (waitHandles, millisecondsTimeout, exitContext);
|
||||
else
|
||||
throw new ArgumentException ();
|
||||
}
|
||||
|
||||
#if false
|
||||
//
|
||||
// Although we should thrown an exception if this is an STA thread,
|
||||
// Mono does not know anything about STA threads, and just makes
|
||||
// things like Paint.NET not even possible to work.
|
||||
//
|
||||
// See bug #78455 for the bug this is supposed to fix.
|
||||
//
|
||||
if (waitAll && length > 1 && IsSTAThread)
|
||||
throw new NotSupportedException ("WaitAll for multiple handles is not allowed on an STA thread.");
|
||||
#endif
|
||||
foreach (WaitHandle w in handles) {
|
||||
if (w == null)
|
||||
throw new ArgumentNullException ("waitHandles", "null handle");
|
||||
|
||||
if (w.safe_wait_handle == null)
|
||||
throw new ArgumentException ("null element found", "waitHandle");
|
||||
|
||||
}
|
||||
}
|
||||
#if false
|
||||
// usage of property is commented - see above
|
||||
static bool IsSTAThread {
|
||||
get {
|
||||
bool isSTA = Thread.CurrentThread.ApartmentState ==
|
||||
ApartmentState.STA;
|
||||
|
||||
// FIXME: remove this check after Thread.ApartmentState
|
||||
// has been properly implemented.
|
||||
if (!isSTA) {
|
||||
Assembly asm = Assembly.GetEntryAssembly ();
|
||||
if (asm != null)
|
||||
isSTA = asm.EntryPoint.GetCustomAttributes (typeof (STAThreadAttribute), false).Length > 0;
|
||||
}
|
||||
|
||||
return isSTA;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public static bool WaitAll(WaitHandle[] waitHandles)
|
||||
{
|
||||
CheckArray (waitHandles, true);
|
||||
return(WaitAll_internal(waitHandles, Timeout.Infinite, false));
|
||||
}
|
||||
|
||||
public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
|
||||
{
|
||||
CheckArray (waitHandles, true);
|
||||
// check negative - except for -1 (which is Timeout.Infinite)
|
||||
if (millisecondsTimeout < Timeout.Infinite)
|
||||
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
|
||||
|
||||
try {
|
||||
if (exitContext) {
|
||||
#if MONOTOUCH
|
||||
throw new NotSupportedException ("exitContext == true is not supported");
|
||||
#else
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
#endif
|
||||
}
|
||||
return(WaitAll_internal(waitHandles, millisecondsTimeout, false));
|
||||
}
|
||||
finally {
|
||||
if (exitContext) SynchronizationAttribute.EnterContext ();
|
||||
return WaitAny_internal (waitHandles, millisecondsTimeout, exitContext);
|
||||
} finally {
|
||||
if (exitContext)
|
||||
SynchronizationAttribute.EnterContext ();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool WaitAll(WaitHandle[] waitHandles,
|
||||
TimeSpan timeout,
|
||||
bool exitContext)
|
||||
{
|
||||
CheckArray (waitHandles, true);
|
||||
long ms = (long) timeout.TotalMilliseconds;
|
||||
|
||||
if (ms < -1 || ms > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException ("timeout");
|
||||
|
||||
try {
|
||||
if (exitContext) {
|
||||
#if MONOTOUCH
|
||||
throw new NotSupportedException ("exitContext == true is not supported");
|
||||
#else
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
#endif
|
||||
}
|
||||
return (WaitAll_internal (waitHandles, (int) ms, exitContext));
|
||||
}
|
||||
finally {
|
||||
if (exitContext) SynchronizationAttribute.EnterContext ();
|
||||
}
|
||||
}
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private static extern int WaitAll_internal(WaitHandle[] handles, int ms, bool exitContext);
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private static extern int WaitAny_internal(WaitHandle[] handles, int ms, bool exitContext);
|
||||
|
||||
// LAMESPEC: Doesn't specify how to signal failures
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
public static int WaitAny(WaitHandle[] waitHandles)
|
||||
static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
|
||||
{
|
||||
CheckArray (waitHandles, false);
|
||||
return(WaitAny_internal(waitHandles, Timeout.Infinite, false));
|
||||
}
|
||||
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
public static int WaitAny(WaitHandle[] waitHandles,
|
||||
int millisecondsTimeout,
|
||||
bool exitContext)
|
||||
{
|
||||
CheckArray (waitHandles, false);
|
||||
// check negative - except for -1 (which is Timeout.Infinite)
|
||||
if (millisecondsTimeout < Timeout.Infinite)
|
||||
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
|
||||
|
||||
try {
|
||||
if (exitContext) {
|
||||
#if MONOTOUCH
|
||||
throw new NotSupportedException ("exitContext == true is not supported");
|
||||
#else
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
if (exitContext)
|
||||
throw new NotSupportedException ("exitContext == true is not supported");
|
||||
#endif
|
||||
}
|
||||
return(WaitAny_internal(waitHandles, millisecondsTimeout, exitContext));
|
||||
}
|
||||
finally {
|
||||
if (exitContext) SynchronizationAttribute.EnterContext ();
|
||||
}
|
||||
}
|
||||
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
public static int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout)
|
||||
{
|
||||
return WaitAny (waitHandles, timeout, false);
|
||||
}
|
||||
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
public static int WaitAny(WaitHandle[] waitHandles, int millisecondsTimeout)
|
||||
{
|
||||
return WaitAny (waitHandles, millisecondsTimeout, false);
|
||||
}
|
||||
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
public static int WaitAny(WaitHandle[] waitHandles,
|
||||
TimeSpan timeout, bool exitContext)
|
||||
{
|
||||
CheckArray (waitHandles, false);
|
||||
long ms = (long) timeout.TotalMilliseconds;
|
||||
|
||||
if (ms < -1 || ms > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException ("timeout");
|
||||
|
||||
bool release = false;
|
||||
try {
|
||||
if (exitContext) {
|
||||
#if MONOTOUCH
|
||||
throw new NotSupportedException ("exitContext == true is not supported");
|
||||
#else
|
||||
if (exitContext)
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
#endif
|
||||
}
|
||||
return (WaitAny_internal(waitHandles, (int) ms, exitContext));
|
||||
|
||||
waitableSafeHandle.DangerousAddRef (ref release);
|
||||
|
||||
return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout, exitContext);
|
||||
} finally {
|
||||
if (release)
|
||||
waitableSafeHandle.DangerousRelease ();
|
||||
|
||||
if (exitContext)
|
||||
SynchronizationAttribute.EnterContext ();
|
||||
}
|
||||
finally {
|
||||
if (exitContext) SynchronizationAttribute.EnterContext ();
|
||||
}
|
||||
}
|
||||
|
||||
protected WaitHandle()
|
||||
{
|
||||
// FIXME
|
||||
}
|
||||
|
||||
public virtual void Close ()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Close ();
|
||||
}
|
||||
|
||||
public const int WaitTimeout = 258;
|
||||
|
||||
//
|
||||
// In 2.0 we use SafeWaitHandles instead of IntPtrs
|
||||
//
|
||||
SafeWaitHandle safe_wait_handle;
|
||||
|
||||
[Obsolete ("In the profiles > 2.x, use SafeHandle instead of Handle")]
|
||||
public virtual IntPtr Handle {
|
||||
get {
|
||||
return safe_wait_handle.DangerousGetHandle ();
|
||||
}
|
||||
|
||||
[SecurityPermission (SecurityAction.LinkDemand, UnmanagedCode = true)]
|
||||
[SecurityPermission (SecurityAction.InheritanceDemand, UnmanagedCode = true)]
|
||||
set {
|
||||
if (value == InvalidHandle)
|
||||
safe_wait_handle = new SafeWaitHandle (InvalidHandle, false);
|
||||
else
|
||||
safe_wait_handle = new SafeWaitHandle (value, true);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern bool WaitOne_internal(IntPtr handle, int ms, bool exitContext);
|
||||
|
||||
protected virtual void Dispose (bool explicitDisposing)
|
||||
{
|
||||
if (!disposed){
|
||||
|
||||
//
|
||||
// This is only the case if the handle was never properly initialized
|
||||
// most likely a bug in the derived class
|
||||
//
|
||||
if (safe_wait_handle == null)
|
||||
return;
|
||||
|
||||
lock (this){
|
||||
if (disposed)
|
||||
return;
|
||||
|
||||
disposed = true;
|
||||
if (safe_wait_handle != null)
|
||||
safe_wait_handle.Dispose ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SafeWaitHandle SafeWaitHandle {
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
get {
|
||||
return safe_wait_handle;
|
||||
}
|
||||
|
||||
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
|
||||
set {
|
||||
if (value == null)
|
||||
safe_wait_handle = new SafeWaitHandle (InvalidHandle, false);
|
||||
else
|
||||
safe_wait_handle = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SignalAndWait (WaitHandle toSignal,
|
||||
WaitHandle toWaitOn)
|
||||
{
|
||||
return SignalAndWait (toSignal, toWaitOn, -1, false);
|
||||
}
|
||||
|
||||
public static bool SignalAndWait (WaitHandle toSignal,
|
||||
WaitHandle toWaitOn,
|
||||
int millisecondsTimeout,
|
||||
bool exitContext)
|
||||
{
|
||||
if (toSignal == null)
|
||||
throw new ArgumentNullException ("toSignal");
|
||||
if (toWaitOn == null)
|
||||
throw new ArgumentNullException ("toWaitOn");
|
||||
|
||||
if (millisecondsTimeout < -1)
|
||||
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
|
||||
|
||||
return SignalAndWait_Internal (toSignal.Handle, toWaitOn.Handle, millisecondsTimeout, exitContext);
|
||||
}
|
||||
|
||||
public static bool SignalAndWait (WaitHandle toSignal,
|
||||
WaitHandle toWaitOn,
|
||||
TimeSpan timeout,
|
||||
bool exitContext)
|
||||
{
|
||||
double ms = timeout.TotalMilliseconds;
|
||||
if (ms > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException ("timeout");
|
||||
|
||||
return SignalAndWait (toSignal, toWaitOn, Convert.ToInt32 (ms), false);
|
||||
}
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
static extern bool SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms, bool exitContext);
|
||||
static extern int WaitOne_internal(IntPtr handle, int ms, bool exitContext);
|
||||
|
||||
public virtual bool WaitOne()
|
||||
static int SignalAndWaitOne (SafeWaitHandle waitHandleToSignal,SafeWaitHandle waitHandleToWaitOn, int millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
|
||||
{
|
||||
CheckDisposed ();
|
||||
bool release = false;
|
||||
bool releaseHandleToSignal = false, releaseHandleToWaitOn = false;
|
||||
try {
|
||||
safe_wait_handle.DangerousAddRef (ref release);
|
||||
return (WaitOne_internal(safe_wait_handle.DangerousGetHandle (), Timeout.Infinite, false));
|
||||
waitHandleToSignal.DangerousAddRef (ref releaseHandleToSignal);
|
||||
waitHandleToWaitOn.DangerousAddRef (ref releaseHandleToWaitOn);
|
||||
|
||||
return SignalAndWait_Internal (waitHandleToSignal.DangerousGetHandle (), waitHandleToWaitOn.DangerousGetHandle (), millisecondsTimeout, exitContext);
|
||||
} finally {
|
||||
if (release)
|
||||
safe_wait_handle.DangerousRelease ();
|
||||
if (releaseHandleToSignal)
|
||||
waitHandleToSignal.DangerousRelease ();
|
||||
if (releaseHandleToWaitOn)
|
||||
waitHandleToWaitOn.DangerousRelease ();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool WaitOne(int millisecondsTimeout, bool exitContext)
|
||||
{
|
||||
CheckDisposed ();
|
||||
// check negative - except for -1 (which is Timeout.Infinite)
|
||||
if (millisecondsTimeout < Timeout.Infinite)
|
||||
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
|
||||
|
||||
bool release = false;
|
||||
try {
|
||||
if (exitContext) {
|
||||
#if !MONOTOUCH
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
#endif
|
||||
}
|
||||
safe_wait_handle.DangerousAddRef (ref release);
|
||||
return (WaitOne_internal(safe_wait_handle.DangerousGetHandle (), millisecondsTimeout, exitContext));
|
||||
} finally {
|
||||
#if !MONOTOUCH
|
||||
if (exitContext)
|
||||
SynchronizationAttribute.EnterContext ();
|
||||
#endif
|
||||
if (release)
|
||||
safe_wait_handle.DangerousRelease ();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool WaitOne (int millisecondsTimeout)
|
||||
{
|
||||
return WaitOne (millisecondsTimeout, false);
|
||||
}
|
||||
|
||||
public virtual bool WaitOne (TimeSpan timeout)
|
||||
{
|
||||
return WaitOne (timeout, false);
|
||||
}
|
||||
|
||||
public virtual bool WaitOne(TimeSpan timeout, bool exitContext)
|
||||
{
|
||||
CheckDisposed ();
|
||||
long ms = (long) timeout.TotalMilliseconds;
|
||||
if (ms < -1 || ms > Int32.MaxValue)
|
||||
throw new ArgumentOutOfRangeException ("timeout");
|
||||
|
||||
bool release = false;
|
||||
try {
|
||||
if (exitContext) {
|
||||
#if !MONOTOUCH
|
||||
SynchronizationAttribute.ExitContext ();
|
||||
#endif
|
||||
}
|
||||
safe_wait_handle.DangerousAddRef (ref release);
|
||||
return (WaitOne_internal(safe_wait_handle.DangerousGetHandle (), (int) ms, exitContext));
|
||||
}
|
||||
finally {
|
||||
#if !MONOTOUCH
|
||||
if (exitContext)
|
||||
SynchronizationAttribute.EnterContext ();
|
||||
#endif
|
||||
if (release)
|
||||
safe_wait_handle.DangerousRelease ();
|
||||
}
|
||||
}
|
||||
|
||||
internal void CheckDisposed ()
|
||||
{
|
||||
if (disposed || safe_wait_handle == null)
|
||||
throw new ObjectDisposedException (GetType ().FullName);
|
||||
}
|
||||
|
||||
public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout)
|
||||
{
|
||||
return WaitAll (waitHandles, millisecondsTimeout, false);
|
||||
}
|
||||
|
||||
public static bool WaitAll(WaitHandle[] waitHandles, TimeSpan timeout)
|
||||
{
|
||||
return WaitAll (waitHandles, timeout, false);
|
||||
}
|
||||
|
||||
protected static readonly IntPtr InvalidHandle = (IntPtr) (-1);
|
||||
bool disposed = false;
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
static extern int SignalAndWait_Internal (IntPtr toSignal, IntPtr toWaitOn, int ms, bool exitContext);
|
||||
}
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace System {
|
||||
* of icalls, do not require an increment.
|
||||
*/
|
||||
#pragma warning disable 169
|
||||
private const int mono_corlib_version = 142;
|
||||
private const int mono_corlib_version = 143;
|
||||
#pragma warning restore 169
|
||||
|
||||
[ComVisible (true)]
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace MonoTests.System.Threading
|
||||
SafeWaitHandle swh1 = are1.SafeWaitHandle;
|
||||
are1.Handle = (IntPtr) (-1);
|
||||
Assert.IsTrue (swh1 != are1.SafeWaitHandle, "#1");
|
||||
Assert.IsFalse (swh1.IsClosed, "#2");
|
||||
Assert.IsTrue (swh1.IsClosed, "#2"); // After testing on Windows/.NET, IsClosed returns true
|
||||
Assert.IsFalse (swh1.IsInvalid, "#3");
|
||||
Assert.IsFalse (are1.SafeWaitHandle.IsClosed, "#4");
|
||||
Assert.IsTrue (are1.SafeWaitHandle.IsInvalid, "#5");
|
||||
|
||||
@@ -1571,6 +1571,7 @@ ReferenceSources/SecurityContext.cs
|
||||
../../../external/referencesource/mscorlib/system/threading/timeout.cs
|
||||
../../../external/referencesource/mscorlib/system/threading/waithandlecannotbeopenedexception.cs
|
||||
../../../external/referencesource/mscorlib/system/threading/threadpool.cs
|
||||
../../../external/referencesource/mscorlib/system/threading/waithandle.cs
|
||||
|
||||
../../../external/referencesource/mscorlib/system/threading/Tasks/AsyncCausalityTracer.cs
|
||||
../../../external/referencesource/mscorlib/system/threading/Tasks/BeginEndAwaitableAdapter.cs
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
* Changes which are already detected at runtime, like the addition
|
||||
* of icalls, do not require an increment.
|
||||
*/
|
||||
#define MONO_CORLIB_VERSION 142
|
||||
#define MONO_CORLIB_VERSION 143
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
@@ -286,7 +286,6 @@ typedef struct {
|
||||
typedef struct {
|
||||
MonoMarshalByRefObject object;
|
||||
gpointer handle;
|
||||
MonoBoolean disposed;
|
||||
} MonoWaitHandle;
|
||||
|
||||
/* This is a copy of System.Runtime.Remoting.Messaging.CallType */
|
||||
|
||||
+7
-14
@@ -6604,23 +6604,16 @@ mono_wait_handle_get_handle (MonoWaitHandle *handle)
|
||||
{
|
||||
MONO_REQ_GC_UNSAFE_MODE;
|
||||
|
||||
static MonoClassField *f_os_handle;
|
||||
static MonoClassField *f_safe_handle;
|
||||
static MonoClassField *f_safe_handle = NULL;
|
||||
MonoSafeHandle *sh;
|
||||
|
||||
if (!f_os_handle && !f_safe_handle) {
|
||||
f_os_handle = mono_class_get_field_from_name (mono_defaults.manualresetevent_class, "os_handle");
|
||||
f_safe_handle = mono_class_get_field_from_name (mono_defaults.manualresetevent_class, "safe_wait_handle");
|
||||
if (!f_safe_handle) {
|
||||
f_safe_handle = mono_class_get_field_from_name (mono_defaults.manualresetevent_class, "safeWaitHandle");
|
||||
g_assert (f_safe_handle);
|
||||
}
|
||||
|
||||
if (f_os_handle) {
|
||||
HANDLE retval;
|
||||
mono_field_get_value ((MonoObject*)handle, f_os_handle, &retval);
|
||||
return retval;
|
||||
} else {
|
||||
MonoSafeHandle *sh;
|
||||
mono_field_get_value ((MonoObject*)handle, f_safe_handle, &sh);
|
||||
return sh->handle;
|
||||
}
|
||||
mono_field_get_value ((MonoObject*)handle, f_safe_handle, &sh);
|
||||
return sh->handle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -95,10 +95,10 @@ gboolean ves_icall_System_Threading_Events_ResetEvent_internal (HANDLE handle);
|
||||
void ves_icall_System_Threading_Events_CloseEvent_internal (HANDLE handle);
|
||||
HANDLE ves_icall_System_Threading_Events_OpenEvent_internal (MonoString *name, gint32 rights, gint32 *error);
|
||||
|
||||
gboolean ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
|
||||
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
|
||||
gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext);
|
||||
gboolean ves_icall_System_Threading_WaitHandle_WaitOne_internal(MonoObject *this_obj, HANDLE handle, gint32 ms, gboolean exitContext);
|
||||
gboolean ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext);
|
||||
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms, gboolean exitContext);
|
||||
gint32 ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext);
|
||||
|
||||
MonoArray* ves_icall_System_Threading_Thread_ByteArrayToRootDomain (MonoArray *arr);
|
||||
MonoArray* ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArray *arr);
|
||||
|
||||
+6
-22
@@ -1583,7 +1583,7 @@ mono_wait_uninterrupted (MonoInternalThread *thread, gboolean multiple, guint32
|
||||
}
|
||||
|
||||
/* FIXME: exitContext isnt documented */
|
||||
gboolean ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext)
|
||||
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms, gboolean exitContext)
|
||||
{
|
||||
HANDLE *handles;
|
||||
guint32 numhandles;
|
||||
@@ -1616,15 +1616,7 @@ gboolean ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_
|
||||
|
||||
g_free(handles);
|
||||
|
||||
if(ret==WAIT_FAILED) {
|
||||
THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") Wait failed", __func__, mono_native_thread_id_get ()));
|
||||
return(FALSE);
|
||||
} else if(ret==WAIT_TIMEOUT) {
|
||||
THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") Wait timed out", __func__, mono_native_thread_id_get ()));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* FIXME: exitContext isnt documented */
|
||||
@@ -1676,7 +1668,7 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
|
||||
}
|
||||
|
||||
/* FIXME: exitContext isnt documented */
|
||||
gboolean ves_icall_System_Threading_WaitHandle_WaitOne_internal(MonoObject *this_obj, HANDLE handle, gint32 ms, gboolean exitContext)
|
||||
gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms, gboolean exitContext)
|
||||
{
|
||||
guint32 ret;
|
||||
MonoInternalThread *thread = mono_thread_internal_current ();
|
||||
@@ -1695,18 +1687,10 @@ gboolean ves_icall_System_Threading_WaitHandle_WaitOne_internal(MonoObject *this
|
||||
|
||||
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
|
||||
|
||||
if(ret==WAIT_FAILED) {
|
||||
THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") Wait failed", __func__, mono_native_thread_id_get ()));
|
||||
return(FALSE);
|
||||
} else if(ret==WAIT_TIMEOUT) {
|
||||
THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") Wait timed out", __func__, mono_native_thread_id_get ()));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gint32
|
||||
ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, HANDLE toWait, gint32 ms, gboolean exitContext)
|
||||
{
|
||||
guint32 ret;
|
||||
@@ -1725,7 +1709,7 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, H
|
||||
|
||||
mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
|
||||
|
||||
return (!(ret == WAIT_TIMEOUT || ret == WAIT_IO_COMPLETION || ret == WAIT_FAILED));
|
||||
return ret;
|
||||
}
|
||||
|
||||
HANDLE ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
|
||||
|
||||
Reference in new issue
Block a user