summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Threading/Thread.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Threading/Thread.cs')
-rw-r--r--src/mscorlib/src/System/Threading/Thread.cs542
1 files changed, 10 insertions, 532 deletions
diff --git a/src/mscorlib/src/System/Threading/Thread.cs b/src/mscorlib/src/System/Threading/Thread.cs
index 8294c20c4d..d28002729a 100644
--- a/src/mscorlib/src/System/Threading/Thread.cs
+++ b/src/mscorlib/src/System/Threading/Thread.cs
@@ -19,8 +19,6 @@ namespace System.Threading {
using System.Runtime;
using System.Runtime.InteropServices;
using System;
- using System.Security.Permissions;
- using System.Security.Principal;
using System.Globalization;
using System.Collections.Generic;
using System.Runtime.Serialization;
@@ -103,11 +101,7 @@ namespace System.Threading {
}
}
- // deliberately not [serializable]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_Thread))]
- [System.Runtime.InteropServices.ComVisible(true)]
- public sealed class Thread : RuntimeThread, _Thread
+ public sealed class Thread : RuntimeThread
{
/*=========================================================================
** Data accessed from managed code that needs to be defined in
@@ -120,10 +114,6 @@ namespace System.Threading {
private String m_Name;
private Delegate m_Delegate; // Delegate
-#if FEATURE_LEAK_CULTURE_INFO
- private CultureInfo m_CurrentCulture;
- private CultureInfo m_CurrentUICulture;
-#endif
private Object m_ThreadStartArg;
/*=========================================================================
@@ -149,47 +139,25 @@ namespace System.Threading {
private bool m_ForbidExecutionContextMutation;
#endif
- /*=========================================================================
- ** This manager is responsible for storing the global data that is
- ** shared amongst all the thread local stores.
- =========================================================================*/
- static private LocalDataStoreMgr s_LocalDataStoreMgr;
-
- /*=========================================================================
- ** Thread-local data store
- =========================================================================*/
- [ThreadStatic]
- static private LocalDataStoreHolder s_LocalDataStore;
-
// Do not move! Order of above fields needs to be preserved for alignment
// with native code
// See code:#threadCultureInfo
-#if !FEATURE_LEAK_CULTURE_INFO
[ThreadStatic]
internal static CultureInfo m_CurrentCulture;
[ThreadStatic]
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
}
// Adding an empty default ctor for annotation purposes
@@ -209,7 +177,7 @@ namespace System.Threading {
SetStartHelper((Delegate)start,0); //0 will setup Thread with default stackSize
}
- public Thread(ThreadStart start, int maxStackSize) {
+ internal Thread(ThreadStart start, int maxStackSize) {
if (start == null) {
throw new ArgumentNullException(nameof(start));
}
@@ -226,7 +194,7 @@ namespace System.Threading {
SetStartHelper((Delegate)start, 0);
}
- public Thread(ParameterizedThreadStart start, int maxStackSize) {
+ internal Thread(ParameterizedThreadStart start, int maxStackSize) {
if (start == null) {
throw new ArgumentNullException(nameof(start));
}
@@ -236,7 +204,6 @@ namespace System.Threading {
SetStartHelper((Delegate)start, maxStackSize);
}
- [ComVisible(false)]
public override int GetHashCode()
{
return m_ManagedThreadId;
@@ -244,7 +211,6 @@ namespace System.Threading {
extern public new int ManagedThreadId
{
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
get;
}
@@ -310,14 +276,11 @@ namespace System.Threading {
// If we reach here with a null delegate, something is broken. But we'll let the StartInternal method take care of
// reporting an error. Just make sure we dont try to dereference a null delegate.
ThreadHelper t = (ThreadHelper)(m_Delegate.Target);
- ExecutionContext ec = ExecutionContext.Capture(
- ref stackMark,
- ExecutionContext.CaptureOptions.IgnoreSyncCtx);
+ ExecutionContext ec = ExecutionContext.Capture();
t.SetExecutionContextHelper(ec);
}
- IPrincipal principal = null;
- StartInternal(principal, ref stackMark);
+ StartInternal(ref stackMark);
}
internal ExecutionContext ExecutionContext
@@ -333,30 +296,7 @@ namespace System.Threading {
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void StartInternal(IPrincipal principal, ref StackCrawlMark stackMark);
-#if FEATURE_COMPRESSEDSTACK
- /// <internalonly/>
- [DynamicSecurityMethodAttribute()]
- [Obsolete("Thread.SetCompressedStack is no longer supported. Please use the System.Threading.CompressedStack class")]
- public void SetCompressedStack( CompressedStack stack )
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadAPIsNotSupported"));
- }
-
- [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- internal extern IntPtr SetAppDomainStack( SafeCompressedStackHandle csHandle);
-
- [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- internal extern void RestoreAppDomainStack( IntPtr appDomainStack);
-
-
- /// <internalonly/>
- [Obsolete("Thread.GetCompressedStack is no longer supported. Please use the System.Threading.CompressedStack class")]
- public CompressedStack GetCompressedStack()
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadAPIsNotSupported"));
- }
-#endif // #if FEATURE_COMPRESSEDSTACK
+ private extern void StartInternal(ref StackCrawlMark stackMark);
// Helper method to get a logical thread ID for StringBuilder (for
@@ -366,43 +306,6 @@ namespace System.Threading {
internal extern static IntPtr InternalGetCurrentThread();
/*=========================================================================
- ** Raises a ThreadAbortException in the thread, which usually
- ** results in the thread's death. The ThreadAbortException is a special
- ** exception that is not catchable. The finally clauses of all try
- ** statements will be executed before the thread dies. This includes the
- ** finally that a thread might be executing at the moment the Abort is raised.
- ** The thread is not stopped immediately--you must Join on the
- ** thread to guarantee it has stopped.
- ** It is possible for a thread to do an unbounded amount of computation in
- ** the finally's and thus indefinitely delay the threads death.
- ** If Abort() is called on a thread that has not been started, the thread
- ** will abort when Start() is called.
- ** If Abort is called twice on the same thread, a DuplicateThreadAbort
- ** exception is thrown.
- =========================================================================*/
-#pragma warning disable 618
- [SecurityPermissionAttribute(SecurityAction.Demand, ControlThread = true)]
-#pragma warning restore 618
- public void Abort()
- {
- AbortInternal();
- }
-
- // Internal helper (since we can't place security demands on
- // ecalls/fcalls).
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- private extern void AbortInternal();
-
- public bool Join(TimeSpan timeout)
- {
- long tm = (long)timeout.TotalMilliseconds;
- if (tm < -1 || tm > (long) Int32.MaxValue)
- throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1"));
-
- return Join((int)tm);
- }
-
- /*=========================================================================
** Suspends the current thread for timeout milliseconds. If timeout == 0,
** forces the thread to give up the remainer of its timeslice. If timeout
** == Timeout.Infinite, no timeout will occur.
@@ -435,10 +338,8 @@ namespace System.Threading {
a explict busy loop because the hardware can be informed that it is busy waiting. */
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern void SpinWaitInternal(int iterations);
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
public static new void SpinWait(int iterations)
{
SpinWaitInternal(iterations);
@@ -446,17 +347,14 @@ namespace System.Threading {
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
private static extern bool YieldInternal();
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
- public static new bool Yield()
+ internal static new bool Yield()
{
return YieldInternal();
}
public static new Thread CurrentThread {
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
get {
Contract.Ensures(Contract.Result<Thread>() != null);
return GetCurrentThreadNative();
@@ -467,8 +365,7 @@ namespace System.Threading {
private void SetStartHelper(Delegate start, int maxStackSize)
{
- // We only support default stacks in CoreCLR
- Debug.Assert(maxStackSize == 0);
+ Debug.Assert(maxStackSize >= 0);
ThreadHelper threadStartCallBack = new ThreadHelper(start);
if(start is ThreadStart)
@@ -481,10 +378,6 @@ namespace System.Threading {
}
}
- [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern ulong GetProcessDefaultStackSize();
-
/*=========================================================================
** PRIVATE Sets the IThreadable interface for the thread. Assumes that
** start != null.
@@ -495,122 +388,21 @@ namespace System.Threading {
/*=========================================================================
** Clean up the thread when it goes away.
=========================================================================*/
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
~Thread()
{
// Delegate to the unmanaged portion.
InternalFinalize();
}
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void InternalFinalize();
#if FEATURE_COMINTEROP_APARTMENT_SUPPORT
- /*=========================================================================
- ** An unstarted thread can be marked to indicate that it will host a
- ** single-threaded or multi-threaded apartment.
- **
- ** Exceptions: ArgumentException if state is not a valid apartment state
- ** (ApartmentSTA or ApartmentMTA).
- =========================================================================*/
- [Obsolete("The ApartmentState property has been deprecated. Use GetApartmentState, SetApartmentState or TrySetApartmentState instead.", false)]
- public ApartmentState ApartmentState
- {
- get
- {
- return (ApartmentState)GetApartmentStateNative();
- }
-
- set
- {
- SetApartmentStateNative((int)value, true);
- }
- }
-
- public void SetApartmentState(ApartmentState state)
- {
- bool result = SetApartmentStateHelper(state, true);
- if (!result)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ApartmentStateSwitchFailed"));
- }
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void StartupSetApartmentStateInternal();
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
- /*=========================================================================
- ** Allocates an un-named data slot. The slot is allocated on ALL the
- ** threads.
- =========================================================================*/
- public static LocalDataStoreSlot AllocateDataSlot()
- {
- return LocalDataStoreManager.AllocateDataSlot();
- }
-
- /*=========================================================================
- ** Allocates a named data slot. The slot is allocated on ALL the
- ** threads. Named data slots are "public" and can be manipulated by
- ** anyone.
- =========================================================================*/
- public static LocalDataStoreSlot AllocateNamedDataSlot(String name)
- {
- return LocalDataStoreManager.AllocateNamedDataSlot(name);
- }
-
- /*=========================================================================
- ** Looks up a named data slot. If the name has not been used, a new slot is
- ** allocated. Named data slots are "public" and can be manipulated by
- ** anyone.
- =========================================================================*/
- public static LocalDataStoreSlot GetNamedDataSlot(String name)
- {
- return LocalDataStoreManager.GetNamedDataSlot(name);
- }
-
- /*=========================================================================
- ** Frees a named data slot. The slot is allocated on ALL the
- ** threads. Named data slots are "public" and can be manipulated by
- ** anyone.
- =========================================================================*/
- public static void FreeNamedDataSlot(String name)
- {
- LocalDataStoreManager.FreeNamedDataSlot(name);
- }
-
- /*=========================================================================
- ** Retrieves the value from the specified slot on the current thread, for that thread's current domain.
- =========================================================================*/
- public static Object GetData(LocalDataStoreSlot slot)
- {
- LocalDataStoreHolder dls = s_LocalDataStore;
- if (dls == null)
- {
- // Make sure to validate the slot even if we take the quick path
- LocalDataStoreManager.ValidateSlot(slot);
- return null;
- }
-
- return dls.Store.GetData(slot);
- }
-
- /*=========================================================================
- ** Sets the data in the specified slot on the currently running thread, for that thread's current domain.
- =========================================================================*/
- public static void SetData(LocalDataStoreSlot slot, Object data)
- {
- LocalDataStoreHolder dls = s_LocalDataStore;
-
- // Create new DLS if one hasn't been created for this domain for this thread
- if (dls == null) {
- dls = LocalDataStoreManager.CreateLocalDataStore();
- s_LocalDataStore = dls;
- }
-
- dls.Store.SetData(slot, data);
- }
-
-
// #threadCultureInfo
//
// Background:
@@ -623,10 +415,6 @@ namespace System.Threading {
// - thread instance member cultures (CurrentCulture and CurrentUICulture)
// confined within AppDomains
// - changes to these properties don't affect the underlying native thread
- //
- // Ifdef:
- // FEATURE_LEAK_CULTURE_INFO : CultureInfos can leak across AppDomains, not
- // enabled in Silverlight
//
// Implementation notes:
// In Silverlight, culture members thread static (per Thread, per AppDomain).
@@ -636,10 +424,6 @@ namespace System.Threading {
// now need to special case resource lookup for mscorlib, which transitions to the
// default domain to lookup resources. See Environment.cs for more details.
//
-#if FEATURE_LEAK_CULTURE_INFO
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern private bool nativeGetSafeCulture(Thread t, int appDomainId, bool isUI, ref CultureInfo safeCulture);
-#endif // FEATURE_LEAK_CULTURE_INFO
// As the culture can be customized object then we cannot hold any
// reference to it before we check if it is safe because the app domain
@@ -680,16 +464,8 @@ namespace System.Threading {
// If you add more pre-conditions to this method, check to see if you also need to
// add them to CultureInfo.DefaultThreadCurrentUICulture.set.
-#if FEATURE_LEAK_CULTURE_INFO
- if (nativeSetThreadUILocale(value.SortName) == false)
- {
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidResourceCultureName", value.Name));
- }
- value.StartCrossDomainTracking();
-#else
if (m_CurrentUICulture == null && m_CurrentCulture == null)
nativeInitCultureAccessors();
-#endif
if (!AppContextSwitches.NoAsyncCurrentCulture)
{
@@ -708,8 +484,6 @@ namespace System.Threading {
}
}
-#if FEATURE_LEAK_CULTURE_INFO
-#endif
internal CultureInfo GetCurrentUICultureNoAppX() {
Contract.Ensures(Contract.Result<CultureInfo>() != null);
@@ -725,25 +499,11 @@ namespace System.Threading {
return (appDomainDefaultUICulture != null ? appDomainDefaultUICulture : CultureInfo.UserDefaultUICulture);
}
-#if FEATURE_LEAK_CULTURE_INFO
- CultureInfo culture = null;
-
- if (!nativeGetSafeCulture(this, GetDomainID(), true, ref culture) || culture == null) {
- return CultureInfo.UserDefaultUICulture;
- }
-
- return culture;
-#else
return m_CurrentUICulture;
#endif
-#endif
}
// This returns the exposed context for a given context ID.
-#if FEATURE_LEAK_CULTURE_INFO
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- static extern private bool nativeSetThreadUILocale(String locale);
-#endif
// As the culture can be customized object then we cannot hold any
// reference to it before we check if it is safe because the app domain
@@ -772,8 +532,6 @@ namespace System.Threading {
}
}
-#if FEATURE_LEAK_CULTURE_INFO
-#endif
set {
if (null==value) {
throw new ArgumentNullException(nameof(value));
@@ -783,16 +541,8 @@ namespace System.Threading {
// If you add more pre-conditions to this method, check to see if you also need to
// add them to CultureInfo.DefaultThreadCurrentCulture.set.
-#if FEATURE_LEAK_CULTURE_INFO
- //If we can't set the nativeThreadLocale, we'll just let it stay
- //at whatever value it had before. This allows people who use
- //just managed code not to be limited by the underlying OS.
- CultureInfo.nativeSetThreadLocale(value.SortName);
- value.StartCrossDomainTracking();
-#else
if (m_CurrentCulture == null && m_CurrentUICulture == null)
nativeInitCultureAccessors();
-#endif
if (!AppContextSwitches.NoAsyncCurrentCulture)
{
@@ -810,8 +560,6 @@ namespace System.Threading {
}
}
-#if FEATURE_LEAK_CULTURE_INFO
-#endif
private CultureInfo GetCurrentCultureNoAppX() {
#if FEATURE_COREFX_GLOBALIZATION
@@ -826,25 +574,13 @@ namespace System.Threading {
return (appDomainDefaultCulture != null ? appDomainDefaultCulture : CultureInfo.UserDefaultCulture);
}
-#if FEATURE_LEAK_CULTURE_INFO
- CultureInfo culture = null;
-
- if (!nativeGetSafeCulture(this, GetDomainID(), false, ref culture) || culture == null) {
- return CultureInfo.UserDefaultCulture;
- }
-
- return culture;
-#else
return m_CurrentCulture;
#endif
-#endif
}
-#if !FEATURE_LEAK_CULTURE_INFO
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
[SuppressUnmanagedCodeSecurity]
private static extern void nativeInitCultureAccessors();
-#endif
/*======================================================================
** Returns the current domain in which current thread is running.
@@ -855,7 +591,7 @@ namespace System.Threading {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern AppDomain GetFastDomainInternal();
- public static AppDomain GetDomain()
+ internal static AppDomain GetDomain()
{
Contract.Ensures(Contract.Result<AppDomain>() != null);
@@ -872,7 +608,7 @@ namespace System.Threading {
/*
* This returns a unique id to identify an appdomain.
*/
- public static int GetDomainID()
+ internal static int GetDomainID()
{
return GetDomain().GetId();
}
@@ -899,267 +635,9 @@ namespace System.Threading {
[SuppressUnmanagedCodeSecurity]
private static extern void InformThreadNameChange(ThreadHandle t, String name, int len);
- internal Object AbortReason {
- get {
- object result = null;
- try
- {
- result = GetAbortReason();
- }
- catch (Exception e)
- {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ExceptionStateCrossAppDomain"), e);
- }
- return result;
- }
- set { SetAbortReason(value); }
- }
-
- /*=========================================================================
- ** Volatile Read & Write and MemoryBarrier methods.
- ** Provides the ability to read and write values ensuring that the values
- ** are read/written each time they are accessed.
- =========================================================================*/
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static byte VolatileRead(ref byte address)
- {
- byte ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static short VolatileRead(ref short address)
- {
- short ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static int VolatileRead(ref int address)
- {
- int ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static long VolatileRead(ref long address)
- {
- long ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static sbyte VolatileRead(ref sbyte address)
- {
- sbyte ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static ushort VolatileRead(ref ushort address)
- {
- ushort ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static uint VolatileRead(ref uint address)
- {
- uint ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static IntPtr VolatileRead(ref IntPtr address)
- {
- IntPtr ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static UIntPtr VolatileRead(ref UIntPtr address)
- {
- UIntPtr ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static ulong VolatileRead(ref ulong address)
- {
- ulong ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static float VolatileRead(ref float address)
- {
- float ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static double VolatileRead(ref double address)
- {
- double ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static Object VolatileRead(ref Object address)
- {
- Object ret = address;
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- return ret;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref byte address, byte value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref short address, short value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref int address, int value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref long address, long value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref sbyte address, sbyte value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref ushort address, ushort value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref uint address, uint value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref IntPtr address, IntPtr value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref UIntPtr address, UIntPtr value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [CLSCompliant(false)]
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref ulong address, ulong value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref float address, float value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref double address, double value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
- [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations
- public static void VolatileWrite(ref Object address, Object value)
- {
- MemoryBarrier(); // Call MemoryBarrier to ensure the proper semantic in a portable way.
- address = value;
- }
-
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void MemoryBarrier();
- private static LocalDataStoreMgr LocalDataStoreManager
- {
- get
- {
- if (s_LocalDataStoreMgr == null)
- {
- Interlocked.CompareExchange(ref s_LocalDataStoreMgr, new LocalDataStoreMgr(), null);
- }
-
- return s_LocalDataStoreMgr;
- }
- }
-
- // 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).
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern void SetAbortReason(Object o);
-
- // Helper function to retrieve the AbortReason from a thread
- // abort. Will perform cross-AppDomain marshalling if the object
- // lives in a different AppDomain from the requester.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern Object GetAbortReason();
-
- // Helper function to clear the AbortReason. Takes care of
- // AppDomain related cleanup if required.
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal extern void ClearAbortReason();
-
-
} // End of class Thread
// declaring a local var of this enum type and passing it by ref into a function that needs to do a