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

@@ -21,8 +21,8 @@ namespace System.Threading {
using System.Runtime.InteropServices;
#if FEATURE_REMOTING
using System.Runtime.Remoting.Contexts;
#endif
using System.Runtime.Remoting.Messaging;
#endif
using System;
using System.Diagnostics;
using System.Security.Permissions;
@@ -139,7 +139,9 @@ namespace System.Threading {
#if FEATURE_REMOTING
private Context m_Context;
#endif
#if !FEATURE_CORECLR
private ExecutionContext m_ExecutionContext; // this call context follows the logical thread
#endif
private String m_Name;
private Delegate m_Delegate; // Delegate
@@ -190,11 +192,32 @@ namespace System.Threading {
// See code:#threadCultureInfo
#if !FEATURE_LEAK_CULTURE_INFO
[ThreadStatic]
private static CultureInfo m_CurrentCulture;
internal static CultureInfo m_CurrentCulture;
[ThreadStatic]
private static CultureInfo m_CurrentUICulture;
internal static CultureInfo m_CurrentUICulture;
#endif
static AsyncLocal<CultureInfo> s_asyncLocalCurrentCulture;
static AsyncLocal<CultureInfo> s_asyncLocalCurrentUICulture;
static void AsyncLocalSetCurrentCulture(AsyncLocalValueChangedArgs<CultureInfo> args)
{
#if FEATURE_LEAK_CULTURE_INFO
Thread.CurrentThread.m_CurrentCulture = args.CurrentValue;
#else
m_CurrentCulture = args.CurrentValue;
#endif // FEATURE_LEAK_CULTURE_INFO
}
static void AsyncLocalSetCurrentUICulture(AsyncLocalValueChangedArgs<CultureInfo> args)
{
#if FEATURE_LEAK_CULTURE_INFO
Thread.CurrentThread.m_CurrentUICulture = args.CurrentValue;
#else
m_CurrentUICulture = args.CurrentValue;
#endif // FEATURE_LEAK_CULTURE_INFO
}
#if FEATURE_CORECLR
// Adding an empty default ctor for annotation purposes
[System.Security.SecuritySafeCritical] // auto-generated
@@ -331,7 +354,7 @@ namespace System.Threading {
ExecutionContext.CaptureOptions.IgnoreSyncCtx);
t.SetExecutionContextHelper(ec);
}
#if FEATURE_ROLE_BASED_SECURITY
#if FEATURE_IMPERSONATION
IPrincipal principal = (IPrincipal)CallContext.Principal;
#else
IPrincipal principal = null;
@@ -340,6 +363,7 @@ namespace System.Threading {
}
#if !FEATURE_CORECLR
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
internal ExecutionContext.Reader GetExecutionContextReader()
{
@@ -413,6 +437,8 @@ namespace System.Threading {
m_ExecutionContext = value.DangerousGetRawExecutionContext();
ExecutionContextBelongsToCurrentScope = belongsToCurrentScope;
}
#endif //!FEATURE_CORECLR
#if !MONO
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
@@ -456,9 +482,6 @@ namespace System.Threading {
[System.Security.SecurityCritical] // auto-generated
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
#if !FEATURE_CORECLR
[System.Runtime.ForceTokenStabilization]
#endif //!FEATURE_CORECLR
internal extern static IntPtr InternalGetCurrentThread();
/*=========================================================================
@@ -535,7 +558,7 @@ namespace System.Threading {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void AbortInternal();
#endif
#if !FEATURE_CORECLR || MONO
#if (!FEATURE_CORECLR && !MONO) || MONO_FEATURE_THREAD_ABORT
/*=========================================================================
** Resets a thread abort.
** Should be called by trusted code only
@@ -555,7 +578,8 @@ namespace System.Threading {
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void ResetAbortNative();
#endif
#if (!FEATURE_CORECLR && !MONO) || MONO_FEATURE_THREAD_SUSPEND_RESUME
/*=========================================================================
** Suspends the thread. If the thread is already suspended, this call has
** no effect.
@@ -592,7 +616,9 @@ namespace System.Threading {
[ResourceExposure(ResourceScope.None)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void ResumeInternal();
#endif
#if !FEATURE_CORECLR || MONO
/*=========================================================================
** Interrupts a thread that is inside a Wait(), Sleep() or Join(). If that
** thread is not currently blocked in that manner, it will be interrupted
@@ -749,10 +775,15 @@ namespace System.Threading {
}
#endif
[System.Security.SecurityCritical] // auto-generated
[MethodImplAttribute(MethodImplOptions.InternalCall),
HostProtection(Synchronization = true, ExternalThreading = true),
ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success),
ResourceExposure(ResourceScope.None)]
[ResourceExposure(ResourceScope.None)]
#if MONO
[MethodImplAttribute(MethodImplOptions.InternalCall)]
#else
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
#endif
[SuppressUnmanagedCodeSecurity]
[HostProtection(Synchronization = true, ExternalThreading = true),
ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool YieldInternal();
[System.Security.SecuritySafeCritical] // auto-generated
@@ -767,9 +798,6 @@ namespace System.Threading {
public static Thread CurrentThread {
[System.Security.SecuritySafeCritical] // auto-generated
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
get {
Contract.Ensures(Contract.Result<Thread>() != null);
return GetCurrentThreadNative();
@@ -1153,8 +1181,20 @@ namespace System.Threading {
return;
}
#endif
if (!AppContextSwitches.NoAsyncCurrentCulture)
{
if (s_asyncLocalCurrentUICulture == null)
{
Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null);
}
m_CurrentUICulture = value;
// this one will set m_CurrentUICulture too
s_asyncLocalCurrentUICulture.Value = value;
}
else
{
m_CurrentUICulture = value;
}
}
}
@@ -1214,7 +1254,7 @@ namespace System.Threading {
return CultureInfo.GetCultureInfoForUserPreferredLanguageInAppX() ?? GetCurrentCultureNoAppX();
}
else
#endif
#endif
{
return GetCurrentCultureNoAppX();
}
@@ -1252,8 +1292,19 @@ namespace System.Threading {
return;
}
#endif
m_CurrentCulture = value;
if (!AppContextSwitches.NoAsyncCurrentCulture)
{
if (s_asyncLocalCurrentCulture == null)
{
Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null);
}
// this one will set m_CurrentCulture too
s_asyncLocalCurrentCulture.Value = value;
}
else
{
m_CurrentCulture = value;
}
}
}
@@ -1343,15 +1394,11 @@ namespace System.Threading {
[System.Security.SecuritySafeCritical] // auto-generated
[SecurityPermissionAttribute(SecurityAction.Demand, Flags=SecurityPermissionFlag.ControlPrincipal)]
#if !FEATURE_CORECLR
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
#endif
set
{
CallContext.Principal = value;
}
}
#endif // FEATURE_IMPERSONATION
// Private routine called from unmanaged code to set an initial
// principal for a newly created thread.
@@ -1360,6 +1407,7 @@ namespace System.Threading {
{
GetMutableExecutionContext().LogicalCallContext.SecurityData.Principal = principal;
}
#endif // FEATURE_IMPERSONATION
#if FEATURE_REMOTING
@@ -1385,7 +1433,7 @@ namespace System.Threading {
{
return ftnToCall(args);
}
#endif // FEATURE_REMOTING
#endif // FEATURE_REMOTING
/*======================================================================
** Returns the current domain in which current thread is running.
@@ -1759,6 +1807,7 @@ namespace System.Threading {
}
#endif
#if !MONO
// Helper function to set the AbortReason for a thread abort.
// Checks that they're not alredy set, and then atomically updates
// the reason info (object + ADID).