You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
committed by
Jo Shields
parent
183bba2c9a
commit
6992685b86
@@ -110,7 +110,7 @@ namespace System.Threading {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !MONO
|
||||
internal struct ThreadHandle
|
||||
{
|
||||
private IntPtr m_ptr;
|
||||
@@ -120,13 +120,17 @@ namespace System.Threading {
|
||||
m_ptr = pThread;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// deliberately not [serializable]
|
||||
[ClassInterface(ClassInterfaceType.None)]
|
||||
[ComDefaultInterface(typeof(_Thread))]
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
public sealed class Thread : CriticalFinalizerObject, _Thread
|
||||
public sealed partial class Thread : CriticalFinalizerObject
|
||||
#if !MOBILE
|
||||
, _Thread
|
||||
#endif
|
||||
{
|
||||
#if !MONO
|
||||
/*=========================================================================
|
||||
** Data accessed from managed code that needs to be defined in
|
||||
** ThreadBaseObject to maintain alignment between the two classes.
|
||||
@@ -168,7 +172,7 @@ namespace System.Threading {
|
||||
#if DEBUG
|
||||
private bool m_ForbidExecutionContextMutation;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/*=========================================================================
|
||||
** This manager is responsible for storing the global data that is
|
||||
** shared amongst all the thread local stores.
|
||||
@@ -222,6 +226,7 @@ namespace System.Threading {
|
||||
Contract.EndContractBlock();
|
||||
SetStartHelper((Delegate)start, maxStackSize);
|
||||
}
|
||||
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
public Thread(ParameterizedThreadStart start) {
|
||||
if (start == null) {
|
||||
@@ -241,7 +246,7 @@ namespace System.Threading {
|
||||
Contract.EndContractBlock();
|
||||
SetStartHelper((Delegate)start, maxStackSize);
|
||||
}
|
||||
|
||||
#if !MONO
|
||||
[ComVisible(false)]
|
||||
public override int GetHashCode()
|
||||
{
|
||||
@@ -270,7 +275,7 @@ namespace System.Threading {
|
||||
|
||||
return new ThreadHandle(thread);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*=========================================================================
|
||||
** Spawns off a new thread which will begin executing at the ThreadStart
|
||||
@@ -326,7 +331,11 @@ namespace System.Threading {
|
||||
ExecutionContext.CaptureOptions.IgnoreSyncCtx);
|
||||
t.SetExecutionContextHelper(ec);
|
||||
}
|
||||
#if FEATURE_ROLE_BASED_SECURITY
|
||||
IPrincipal principal = (IPrincipal)CallContext.Principal;
|
||||
#else
|
||||
IPrincipal principal = null;
|
||||
#endif
|
||||
StartInternal(principal, ref stackMark);
|
||||
}
|
||||
|
||||
@@ -343,7 +352,7 @@ namespace System.Threading {
|
||||
set { m_ExecutionContextBelongsToOuterScope = !value; }
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
#if !MONO && DEBUG
|
||||
internal bool ForbidExecutionContextMutation
|
||||
{
|
||||
set { m_ForbidExecutionContextMutation = value; }
|
||||
@@ -372,7 +381,7 @@ namespace System.Threading {
|
||||
internal ExecutionContext GetMutableExecutionContext()
|
||||
{
|
||||
Contract.Assert(Thread.CurrentThread == this);
|
||||
#if DEBUG
|
||||
#if !MONO && DEBUG
|
||||
Contract.Assert(!m_ForbidExecutionContextMutation);
|
||||
#endif
|
||||
if (m_ExecutionContext == null)
|
||||
@@ -404,12 +413,13 @@ namespace System.Threading {
|
||||
m_ExecutionContext = value.DangerousGetRawExecutionContext();
|
||||
ExecutionContextBelongsToCurrentScope = belongsToCurrentScope;
|
||||
}
|
||||
|
||||
#if !MONO
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern void StartInternal(IPrincipal principal, ref StackCrawlMark stackMark);
|
||||
#if FEATURE_COMPRESSEDSTACK
|
||||
#endif
|
||||
#if FEATURE_COMPRESSEDSTACK || MONO
|
||||
/// <internalonly/>
|
||||
[System.Security.SecurityCritical] // auto-generated_required
|
||||
[DynamicSecurityMethodAttribute()]
|
||||
@@ -418,7 +428,7 @@ namespace System.Threading {
|
||||
{
|
||||
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadAPIsNotSupported"));
|
||||
}
|
||||
|
||||
#if !MONO
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
@@ -428,7 +438,7 @@ namespace System.Threading {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
|
||||
internal extern void RestoreAppDomainStack( IntPtr appDomainStack);
|
||||
|
||||
#endif
|
||||
|
||||
/// <internalonly/>
|
||||
[System.Security.SecurityCritical] // auto-generated_required
|
||||
@@ -438,7 +448,7 @@ namespace System.Threading {
|
||||
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadAPIsNotSupported"));
|
||||
}
|
||||
#endif // #if FEATURE_COMPRESSEDSTACK
|
||||
|
||||
#if !MONO
|
||||
|
||||
// Helper method to get a logical thread ID for StringBuilder (for
|
||||
// correctness) and for FileStream's async code path (for perf, to
|
||||
@@ -524,8 +534,8 @@ namespace System.Threading {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern void AbortInternal();
|
||||
|
||||
#if !FEATURE_CORECLR
|
||||
#endif
|
||||
#if !FEATURE_CORECLR || MONO
|
||||
/*=========================================================================
|
||||
** Resets a thread abort.
|
||||
** Should be called by trusted code only
|
||||
@@ -621,7 +631,7 @@ namespace System.Threading {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern void SetPriorityNative(int priority);
|
||||
|
||||
#if !MONO
|
||||
/*=========================================================================
|
||||
** Returns true if the thread has been started and is not dead.
|
||||
=========================================================================*/
|
||||
@@ -639,7 +649,7 @@ namespace System.Threading {
|
||||
[MethodImpl(MethodImplOptions.InternalCall)]
|
||||
get;
|
||||
}
|
||||
|
||||
#endif
|
||||
/*=========================================================================
|
||||
** Waits for the thread to die or for timeout milliseconds to elapse.
|
||||
** Returns true if the thread died, or false if the wait timed out. If
|
||||
@@ -665,6 +675,10 @@ namespace System.Threading {
|
||||
[HostProtection(Synchronization=true, ExternalThreading=true)]
|
||||
public bool Join(int millisecondsTimeout)
|
||||
{
|
||||
#if MONO
|
||||
if (millisecondsTimeout < Timeout.Infinite)
|
||||
throw new ArgumentOutOfRangeException("millisecondsTimeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
|
||||
#endif
|
||||
return JoinInternal(millisecondsTimeout);
|
||||
}
|
||||
|
||||
@@ -694,10 +708,16 @@ namespace System.Threading {
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
public static void Sleep(int millisecondsTimeout)
|
||||
{
|
||||
#if MONO
|
||||
if (millisecondsTimeout < Timeout.Infinite)
|
||||
throw new ArgumentOutOfRangeException("millisecondsTimeout", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
|
||||
#endif
|
||||
SleepInternal(millisecondsTimeout);
|
||||
#if !MONO
|
||||
// Ensure we don't return to app code when the pause is underway
|
||||
if(AppDomainPauseManager.IsPaused)
|
||||
AppDomainPauseManager.ResumeEvent.WaitOneWithoutFAS();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Sleep(TimeSpan timeout)
|
||||
@@ -708,7 +728,7 @@ namespace System.Threading {
|
||||
Sleep((int)tm);
|
||||
}
|
||||
|
||||
|
||||
#if !MONO
|
||||
/* wait for a length of time proportial to 'iterations'. Each iteration is should
|
||||
only take a few machine instructions. Calling this API is preferable to coding
|
||||
a explict busy loop because the hardware can be informed that it is busy waiting. */
|
||||
@@ -727,7 +747,7 @@ namespace System.Threading {
|
||||
{
|
||||
SpinWaitInternal(iterations);
|
||||
}
|
||||
|
||||
#endif
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall),
|
||||
HostProtection(Synchronization = true, ExternalThreading = true),
|
||||
@@ -742,7 +762,8 @@ namespace System.Threading {
|
||||
{
|
||||
return YieldInternal();
|
||||
}
|
||||
|
||||
|
||||
#if !MONO
|
||||
public static Thread CurrentThread {
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
@@ -758,10 +779,13 @@ namespace System.Threading {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
|
||||
private static extern Thread GetCurrentThreadNative();
|
||||
|
||||
#endif
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
private void SetStartHelper(Delegate start, int maxStackSize)
|
||||
{
|
||||
#if MONO
|
||||
maxStackSize = GetProcessDefaultStackSize(maxStackSize);
|
||||
#else
|
||||
#if FEATURE_CORECLR
|
||||
// We only support default stacks in CoreCLR
|
||||
Contract.Assert(maxStackSize == 0);
|
||||
@@ -769,6 +793,7 @@ namespace System.Threading {
|
||||
// Only fully-trusted code is allowed to create "large" stacks. Partial-trust falls back to
|
||||
// the default stack size.
|
||||
ulong defaultStackSize = GetProcessDefaultStackSize();
|
||||
|
||||
if ((ulong)(uint)maxStackSize > defaultStackSize)
|
||||
{
|
||||
try
|
||||
@@ -780,6 +805,7 @@ namespace System.Threading {
|
||||
maxStackSize = (int)Math.Min(defaultStackSize, (ulong)(uint)int.MaxValue);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ThreadHelper threadStartCallBack = new ThreadHelper(start);
|
||||
@@ -792,7 +818,7 @@ namespace System.Threading {
|
||||
SetStart(new ParameterizedThreadStart(threadStartCallBack.ThreadStart), maxStackSize);
|
||||
}
|
||||
}
|
||||
|
||||
#if !MONO
|
||||
[SecurityCritical]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
|
||||
@@ -948,7 +974,7 @@ namespace System.Threading {
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern void StartupSetApartmentStateInternal();
|
||||
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
|
||||
|
||||
#endif
|
||||
/*=========================================================================
|
||||
** Allocates an un-named data slot. The slot is allocated on ALL the
|
||||
** threads.
|
||||
@@ -1027,7 +1053,7 @@ namespace System.Threading {
|
||||
|
||||
dls.Store.SetData(slot, data);
|
||||
}
|
||||
|
||||
#if !MONO
|
||||
|
||||
// #threadCultureInfo
|
||||
//
|
||||
@@ -1693,7 +1719,7 @@ namespace System.Threading {
|
||||
MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
|
||||
address = value;
|
||||
}
|
||||
|
||||
#endif
|
||||
[System.Security.SecuritySafeCritical] // auto-generated
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
@@ -1711,7 +1737,7 @@ namespace System.Threading {
|
||||
return s_LocalDataStoreMgr;
|
||||
}
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
void _Thread.GetTypeInfoCount(out uint pcTInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -1731,7 +1757,8 @@ namespace System.Threading {
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#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).
|
||||
@@ -1754,7 +1781,7 @@ namespace System.Threading {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
internal extern void ClearAbortReason();
|
||||
|
||||
#endif
|
||||
|
||||
} // End of class Thread
|
||||
|
||||
|
Reference in New Issue
Block a user