Imported Upstream version 4.3.2.467

Former-commit-id: 9c2cb47f45fa221e661ab616387c9cda183f283d
This commit is contained in:
Xamarin Public Jenkins
2016-02-22 11:00:01 -05:00
parent f302175246
commit f3e3aab35a
4097 changed files with 122406 additions and 82300 deletions

View File

@@ -579,9 +579,7 @@ namespace System.Threading
// The head and tail of the queue. We enqueue to the head, and dequeue from the tail.
internal volatile QueueSegment queueHead;
internal volatile QueueSegment queueTail;
#if !FEATURE_CORECLR
internal bool loggingEnabled;
#endif
internal static SparseArray<WorkStealingQueue> allThreadQueues = new SparseArray<WorkStealingQueue>(16); //
@@ -590,7 +588,7 @@ namespace System.Threading
public ThreadPoolWorkQueue()
{
queueTail = queueHead = new QueueSegment();
#if !MONO && !FEATURE_CORECLR
#if !MONO
loggingEnabled = FrameworkEventSource.Log.IsEnabled(EventLevel.Verbose, FrameworkEventSource.Keywords.ThreadPool|FrameworkEventSource.Keywords.ThreadTransfer);
#endif
}
@@ -652,7 +650,7 @@ namespace System.Threading
if (!forceGlobal)
tl = ThreadPoolWorkQueueThreadLocals.threadLocals;
#if !MONO && !FEATURE_CORECLR
#if !MONO
if (loggingEnabled)
System.Diagnostics.Tracing.FrameworkEventSource.Log.ThreadPoolEnqueueWorkObject(callback);
#endif
@@ -764,7 +762,7 @@ namespace System.Threading
//
workQueue.MarkThreadRequestSatisfied();
#if !MONO && !FEATURE_CORECLR
#if !MONO
// Has the desire for logging changed since the last time we entered?
workQueue.loggingEnabled = FrameworkEventSource.Log.IsEnabled(EventLevel.Verbose, FrameworkEventSource.Keywords.ThreadPool|FrameworkEventSource.Keywords.ThreadTransfer);
#endif
@@ -826,7 +824,7 @@ namespace System.Threading
}
else
{
#if !MONO && !FEATURE_CORECLR
#if !MONO
if (workQueue.loggingEnabled)
System.Diagnostics.Tracing.FrameworkEventSource.Log.ThreadPoolDequeueWorkObject(workItem);
#endif
@@ -1190,9 +1188,27 @@ namespace System.Threading
//
internal static class _ThreadPoolWaitCallback
{
#if FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK
// This feature is used by Xamarin.iOS to use an NSAutoreleasePool
// for every task done by the threadpool.
static Func<Func<bool>, bool> dispatcher;
internal static void SetDispatcher (Func<Func<bool>, bool> value)
{
dispatcher = value;
}
#endif
[System.Security.SecurityCritical]
static internal bool PerformWaitCallback()
{
#if FEATURE_INTERCEPTABLE_THREADPOOL_CALLBACK
// store locally first to ensure another thread doesn't clear the field between checking for null and using it.
var dispatcher = _ThreadPoolWaitCallback.dispatcher;
if (dispatcher != null)
return dispatcher (ThreadPoolWorkQueue.Dispatch);
#endif
return ThreadPoolWorkQueue.Dispatch();
}
}