Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorLudovic Henry <ludovic@xamarin.com>2017-06-17 04:01:51 +0300
committerGitHub <noreply@github.com>2017-06-17 04:01:51 +0300
commit6fc58f529b10f664c71bb301ed9d3524ed4e4f87 (patch)
treee34a8c4492372cc34a5140f94ff99f490ddfc22d /mcs
parent77a8ed1b39af8caa6da04163605ec40283942062 (diff)
[w32handle] Unify WaitHandle.Wait{One,Any,All} icalls (#5051)
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/Mono.Debugger.Soft/Test/dtest.cs2
-rw-r--r--mcs/class/corlib/System.Threading/WaitHandle.cs31
2 files changed, 18 insertions, 15 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
index 8d22ac808b2..7a16e5dcb83 100644
--- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
+++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs
@@ -4145,7 +4145,7 @@ public class DebuggerTests
frames = thread.GetFrames ();
Assert.AreEqual (8, frames.Length, "#7");
- Assert.AreEqual ("WaitOne_internal", frames [0].Method.Name, "#8.0");
+ Assert.AreEqual ("Wait_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");
diff --git a/mcs/class/corlib/System.Threading/WaitHandle.cs b/mcs/class/corlib/System.Threading/WaitHandle.cs
index dd91330355e..0e16f046e80 100644
--- a/mcs/class/corlib/System.Threading/WaitHandle.cs
+++ b/mcs/class/corlib/System.Threading/WaitHandle.cs
@@ -49,6 +49,9 @@ namespace System.Threading
static int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll)
{
+ if (waitHandles.Length > MaxWaitHandles)
+ return WAIT_FAILED;
+
int release_last = -1;
try {
@@ -58,8 +61,7 @@ namespace System.Threading
#endif
for (int i = 0; i < waitHandles.Length; ++i) {
- try {
- } finally {
+ try {} finally {
/* we have to put it in a finally block, to avoid having a ThreadAbortException
* between the return from DangerousAddRef and the assignement to release_last */
bool release = false;
@@ -68,10 +70,14 @@ namespace System.Threading
}
}
- if (WaitAll)
- return WaitAll_internal (waitHandles, millisecondsTimeout);
- else
- return WaitAny_internal (waitHandles, millisecondsTimeout);
+ unsafe {
+ IntPtr* handles = stackalloc IntPtr[waitHandles.Length];
+
+ for (int i = 0; i < waitHandles.Length; ++i)
+ handles[i] = waitHandles[i].SafeWaitHandle.DangerousGetHandle ();
+
+ return Wait_internal(handles, waitHandles.Length, WaitAll, millisecondsTimeout);
+ }
} finally {
for (int i = release_last; i >= 0; --i) {
waitHandles [i].SafeWaitHandle.DangerousRelease ();
@@ -84,12 +90,6 @@ namespace System.Threading
}
}
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int WaitAll_internal(WaitHandle[] handles, int ms);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private static extern int WaitAny_internal(WaitHandle[] handles, int ms);
-
static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
bool release = false;
@@ -101,7 +101,10 @@ namespace System.Threading
waitableSafeHandle.DangerousAddRef (ref release);
- return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout);
+ unsafe {
+ IntPtr handle = waitableSafeHandle.DangerousGetHandle();
+ return Wait_internal(&handle, 1, false, (int)millisecondsTimeout);
+ }
} finally {
if (release)
waitableSafeHandle.DangerousRelease ();
@@ -114,7 +117,7 @@ namespace System.Threading
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern int WaitOne_internal(IntPtr handle, int ms);
+ unsafe static extern int Wait_internal(IntPtr* handles, int numHandles, bool waitAll, int ms);
static int SignalAndWaitOne (SafeWaitHandle waitHandleToSignal,SafeWaitHandle waitHandleToWaitOn, int millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{