Moved ManualResetEventSlim to shared (#18799)
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Mon, 9 Jul 2018 09:21:55 +0000 (02:21 -0700)
committerGitHub <noreply@github.com>
Mon, 9 Jul 2018 09:21:55 +0000 (02:21 -0700)
* Moved ManualResetEventSlim to shared

* covert System.int to System.Int32

src/System.Private.CoreLib/System.Private.CoreLib.csproj
src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs [moved from src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs with 98% similarity]
src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs
src/System.Private.CoreLib/src/System/Threading/SpinLock.cs
src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs

index 92eb180..0dda24d 100644 (file)
     <Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandle.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\SpinLock.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\ThreadLocal.cs" />
-    <Compile Include="$(BclSourcesRoot)\System\Threading\ManualResetEventSlim.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\CancellationTokenRegistration.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\CancellationTokenSource.cs" />
     <Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\future.cs" />
index 19c48e8..8b66d37 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LazyThreadSafetyMode.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\LockRecursionException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEvent.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEventSlim.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Mutex.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\NativeOverlapped.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ParameterizedThreadStart.cs" />
@@ -1,16 +1,6 @@
 // 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.
-#pragma warning disable 0420
-
-// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
-//
-// SlimManualResetEvent.cs
-//
-//
-// An manual-reset event that mixes a little spinning with a true Win32 event.
-//
-// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
 using System.Diagnostics;
 
@@ -265,7 +255,7 @@ namespace System.Threading
             if (Interlocked.CompareExchange(ref m_eventObj, newEventObj, null) != null)
             {
                 // Someone else set the value due to a race condition. Destroy the garbage event.
-                newEventObj.Close();
+                newEventObj.Dispose();
 
                 return false;
             }
@@ -342,7 +332,7 @@ namespace System.Threading
                 // necessary.  However, the coding pattern { event.Wait(); event.Dispose() } is
                 // quite common, and we must support it.  If the waiter woke up and disposed of
                 // the event object before the setter has finished, however, we would try to set a
-                // now-disposed Win32 event.  Crash!  To deal with this race condition, we use a lock to
+                // now-disposed Win32 event. Crash! To deal with this race condition, we use a lock to
                 // protect access to the event object when setting and disposing of it.  We also
                 // double-check that the event has not become null in the meantime when in the lock.
 
@@ -438,7 +428,7 @@ namespace System.Threading
         /// false.</returns>
         /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative
         /// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
-        /// than <see cref="System.int.MaxValue"/>.</exception>
+        /// than <see cref="System.Int32.MaxValue"/>.</exception>
         /// <exception cref="T:System.InvalidOperationException">
         /// The maximum number of waiters has been exceeded.
         /// </exception>
@@ -467,7 +457,7 @@ namespace System.Threading
         /// false.</returns>
         /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative
         /// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
-        /// than <see cref="System.int.MaxValue"/>.</exception>
+        /// than <see cref="System.Int32.MaxValue"/>.</exception>
         /// <exception cref="T:System.Threading.OperationCanceledException"><paramref
         /// name="cancellationToken"/> was canceled.</exception>
         /// <exception cref="T:System.InvalidOperationException">
@@ -622,7 +612,6 @@ namespace System.Threading
                                 // Clean up: we're done waiting.
                                 Waiters = Waiters - 1;
                             }
-
                             // Now just loop back around, and the right thing will happen.  Either:
                             //     1. We had a spurious wake-up due to some other wait being canceled via a different cancellationToken (rewait)
                             // or  2. the wait was successful. (the loop will break)
@@ -672,7 +661,7 @@ namespace System.Threading
                 {
                     lock (eventObj)
                     {
-                        eventObj.Close();
+                        eventObj.Dispose();
                         m_eventObj = null;
                     }
                 }
index d235692..414ad18 100644 (file)
@@ -255,7 +255,7 @@ namespace System.Threading
         /// <exception cref="ArgumentNullException">The <paramref name="condition"/> argument is null.</exception>
         /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative number
         /// other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than
-        /// <see cref="System.int.MaxValue"/>.</exception>
+        /// <see cref="System.Int32.MaxValue"/>.</exception>
         public static bool SpinUntil(Func<bool> condition, TimeSpan timeout)
         {
             // Validate the timeout
index bafe63f..64dfd0c 100644 (file)
@@ -219,7 +219,7 @@ namespace System.Threading
         /// </exception>
         /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative
         /// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
-        /// than <see cref="System.int.MaxValue"/> milliseconds.
+        /// than <see cref="System.Int32.MaxValue"/> milliseconds.
         /// </exception>
         public void TryEnter(TimeSpan timeout, ref bool lockTaken)
         {
index a8926bb..3457c95 100644 (file)
@@ -2718,7 +2718,7 @@ namespace System.Threading.Tasks
         /// <exception cref="T:System.ArgumentOutOfRangeException">
         /// <paramref name="timeout"/> is a negative number other than -1 milliseconds, which represents an
         /// infinite time-out -or- timeout is greater than
-        /// <see cref="System.int.MaxValue"/>.
+        /// <see cref="System.Int32.MaxValue"/>.
         /// </exception>
         public bool Wait(TimeSpan timeout)
         {
@@ -4521,7 +4521,7 @@ namespace System.Threading.Tasks
         /// <exception cref="T:System.ArgumentOutOfRangeException">
         /// <paramref name="timeout"/> is a negative number other than -1 milliseconds, which represents an
         /// infinite time-out -or- timeout is greater than
-        /// <see cref="System.int.MaxValue"/>.
+        /// <see cref="System.Int32.MaxValue"/>.
         /// </exception>
         [MethodImpl(MethodImplOptions.NoOptimization)]  // this is needed for the parallel debugger
         public static bool WaitAll(Task[] tasks, TimeSpan timeout)
@@ -4908,7 +4908,7 @@ namespace System.Threading.Tasks
         /// <exception cref="T:System.ArgumentOutOfRangeException">
         /// <paramref name="timeout"/> is a negative number other than -1 milliseconds, which represents an
         /// infinite time-out -or- timeout is greater than
-        /// <see cref="System.int.MaxValue"/>.
+        /// <see cref="System.Int32.MaxValue"/>.
         /// </exception>
         [MethodImpl(MethodImplOptions.NoOptimization)]  // this is needed for the parallel debugger
         public static int WaitAny(Task[] tasks, TimeSpan timeout)