Преглед изворни кода

[corlib] Cleans up few static ctors

Marek Safar пре 7 година
родитељ
комит
f3fecf91fb

+ 2 - 8
mcs/class/corlib/System.Threading/Timer.cs

@@ -66,7 +66,7 @@ namespace System.Threading
 	public sealed class Timer
 		: MarshalByRefObject, IDisposable
 	{
-		static readonly Scheduler scheduler = Scheduler.Instance;
+		static Scheduler scheduler => Scheduler.Instance;
 #region Timer instance fields
 		TimerCallback callback;
 		object state;
@@ -223,7 +223,7 @@ namespace System.Threading
 		}
 
 		sealed class Scheduler {
-			static Scheduler instance;
+			static readonly Scheduler instance = new Scheduler ();
 			SortedList list;
 
 #if WASM
@@ -280,12 +280,6 @@ namespace System.Threading
 			}
 
 #endif
-
-			static Scheduler ()
-			{
-				instance = new Scheduler ();
-			}
-
 			public static Scheduler Instance {
 				get { return instance; }
 			}

+ 2 - 0
mcs/class/referencesource/mscorlib/system/threading/thread.cs

@@ -40,8 +40,10 @@ namespace System.Threading {
 
     internal class ThreadHelper
     {
+#if !MONO
         [System.Security.SecuritySafeCritical]
         static ThreadHelper() {}
+#endif
 
         Delegate _start;
         Object _startArg = null;

+ 16 - 0
mcs/class/referencesource/mscorlib/system/threading/threadpool.cs

@@ -78,6 +78,19 @@ namespace System.Threading
 
     internal static class ThreadPoolGlobals
     {
+#if MONO
+        public const uint tpQuantum = 30U;
+
+        public static int processorCount => Environment.ProcessorCount;
+
+        public static bool tpHosted => ThreadPool.IsThreadPoolHosted(); 
+
+        public static volatile bool vmTpInitialized;
+        public static bool enableWorkerTracking;
+
+        [SecurityCritical]
+        public static readonly ThreadPoolWorkQueue workQueue = new ThreadPoolWorkQueue();
+#else
         //Per-appDomain quantum (in ms) for which the thread keeps processing
         //requests in the current domain.
         public static uint tpQuantum = 30U;
@@ -96,6 +109,7 @@ namespace System.Threading
         static ThreadPoolGlobals()
         {
         }
+#endif
     }
 
     internal sealed class ThreadPoolWorkQueue
@@ -1216,8 +1230,10 @@ namespace System.Threading
 
     internal sealed class QueueUserWorkItemCallback : IThreadPoolWorkItem
     {
+#if !MONO
         [System.Security.SecuritySafeCritical]
         static QueueUserWorkItemCallback() {}
+#endif
 
         private WaitCallback callback;
         private ExecutionContext context;