Просмотр исходного кода

[corlib] Replace few threading types from reference sources

Marek Safar 11 лет назад
Родитель
Сommit
15cb0daaa0

+ 32 - 0
mcs/class/corlib/ReferenceSources/ExecutionContext.cs

@@ -0,0 +1,32 @@
+namespace System.Threading
+{
+	partial class ExecutionContext
+	{
+		internal static ExecutionContext Capture (ref StackCrawlMark stackMark, CaptureOptions options)
+		{
+			// For References sources compatibility only
+			return null;
+		}
+
+	    [Flags]
+	    internal enum CaptureOptions
+	    {
+	        None = 0x00,
+
+	        IgnoreSyncCtx = 0x01,       //Don't flow SynchronizationContext
+
+	        OptimizeDefaultCase = 0x02, //Faster in the typical case, but can't show the result to users
+	                                    // because they could modify the shared default EC.
+	                                    // Use this only if you won't be exposing the captured EC to users.
+	    }
+	}
+
+    [Serializable]
+    internal enum StackCrawlMark
+    {
+        LookForMe = 0,
+        LookForMyCaller = 1,
+        LookForMyCallersCaller = 2,
+        LookForThread = 3
+    }
+}

+ 1 - 1
mcs/class/corlib/System.Threading/ExecutionContext.cs

@@ -38,7 +38,7 @@ using System.Collections.Generic;
 
 namespace System.Threading {
 	[Serializable]
-	public sealed class ExecutionContext : ISerializable
+	public sealed partial class ExecutionContext : ISerializable
 #if NET_4_0
 		, IDisposable
 #endif

+ 1 - 1
mcs/class/corlib/Test/System.Threading/ManualResetEventSlimTests.cs

@@ -230,7 +230,7 @@ namespace MonoTests.System.Threading
 				int count = 2;
 				SpinWait wait = new SpinWait ();
 
-				ThreadPool.QueueUserWorkItem (_ => { mre.Set (); Interlocked.Decrement (ref count); });
+				ThreadPool.QueueUserWorkItem (_ => { while (count > 1) wait.SpinOnce (); mre.Set (); Interlocked.Decrement (ref count); });
 				ThreadPool.QueueUserWorkItem (_ => { mre.Reset (); Interlocked.Decrement (ref count); });
 
 				while (count > 0)

+ 8 - 6
mcs/class/corlib/corlib.dll.sources

@@ -678,7 +678,6 @@ System.Runtime.CompilerServices/IDispatchConstantAttribute.cs
 System.Runtime.CompilerServices/IUnknownConstantAttribute.cs
 System.Runtime.CompilerServices/IndexerNameAttribute.cs
 System.Runtime.CompilerServices/INotifyCompletion.cs
-System.Runtime.CompilerServices/InternalsVisibleToAttribute.cs
 System.Runtime.CompilerServices/IsBoxed.cs
 System.Runtime.CompilerServices/IsByValue.cs
 System.Runtime.CompilerServices/IsConst.cs
@@ -1643,14 +1642,9 @@ System.Threading.Tasks/TaskConstants.cs
 System.Threading.Tasks/TaskConstants_T.cs
 System.Collections.Concurrent/ConcurrentOrderedList.cs
 System.Threading/LazyInitializer.cs
-System.Threading/CountdownEvent.cs
-System.Threading/CancellationTokenSource.cs
-System.Threading/CancellationToken.cs
 System.Threading/SemaphoreSlim.cs
-System.Threading/CancellationTokenRegistration.cs
 System.Threading/SpinLock.cs
 System.Threading/AtomicBoolean.cs
-System.Threading/ManualResetEventSlim.cs
 System.Threading/ThreadLocal.cs
 System.Threading/Watch.cs
 System.Threading.Tasks/ParallelOptions.cs
@@ -1666,6 +1660,7 @@ System.Threading.Tasks/TaskExtensionsImpl.cs
 
 ReferenceSources/Array.cs
 ReferenceSources/Environment.cs
+ReferenceSources/ExecutionContext.cs
 ReferenceSources/Helpers.cs
 ../../../external/referencesource/mscorlib/system/throwhelper.cs
 ../../../external/referencesource/mscorlib/system/collections/generic/debugview.cs
@@ -1677,4 +1672,11 @@ ReferenceSources/Helpers.cs
 ../../../external/referencesource/mscorlib/system/collections/Concurrent/Partitioner.cs
 ../../../external/referencesource/mscorlib/system/collections/Concurrent/PartitionerStatic.cs
 
+../../../external/referencesource/mscorlib/system/threading/CancellationToken.cs
+../../../external/referencesource/mscorlib/system/threading/CancellationTokenRegistration.cs
+../../../external/referencesource/mscorlib/system/threading/CancellationTokenSource.cs
+../../../external/referencesource/mscorlib/system/threading/CountdownEvent.cs
+../../../external/referencesource/mscorlib/system/threading/ManualResetEventSlim.cs
 ../../../external/referencesource/mscorlib/system/threading/SpinWait.cs
+
+../../../external/referencesource/mscorlib/system/runtime/compilerservices/internalsvisibletoattribute.cs