[threads] Remove ThreadState_StopRequested (#4462)
[mono.git] / mcs / class / corlib / System.Threading / Thread.cs
index f1924b22e07ef7e603d8d2446de8ff0a85ff1e7a..c6564db34730f631515ea77b99de90790a6a32c4 100644 (file)
@@ -49,10 +49,9 @@ namespace System.Threading {
                #region Sync with metadata/object-internals.h
                int lock_thread_id;
                // stores a thread handle
-               internal IntPtr system_thread_handle;
-
-               /* Note this is an opaque object (an array), not a CultureInfo */
-               private object cached_culture_info;
+               IntPtr handle;
+               IntPtr native_handle; // used only on Win32
+               IntPtr unused3;
                /* accessed only from unmanaged code */
                private IntPtr name;
                private int name_len; 
@@ -61,12 +60,7 @@ namespace System.Threading {
                private int abort_state_handle;
                /* thread_id is only accessed from unmanaged code */
                internal Int64 thread_id;
-               
-               /* start_notify is used by the runtime to signal that Start()
-                * is ok to return
-                */
-               private IntPtr start_notify;
-               private IntPtr stack_ptr;
+               private IntPtr debugger_thread; // FIXME switch to bool as soon as CI testing with corlib version bump works
                private UIntPtr static_data; /* GC-tracked */
                private IntPtr runtime_thread_info;
                /* current System.Runtime.Remoting.Contexts.Context instance
@@ -87,25 +81,36 @@ namespace System.Threading {
                internal int managed_id;
                private int small_id;
                private IntPtr manage_callback;
-               private IntPtr interrupt_on_stop;
+               private IntPtr unused4;
                private IntPtr flags;
                private IntPtr thread_pinning_ref;
-               private IntPtr start_notify_refcount;
+               private IntPtr abort_protected_block_count;
+               private int priority = (int) ThreadPriority.Normal;
+               private IntPtr owned_mutex;
+               private IntPtr suspended_event;
+               private int self_suspended;
                /* 
                 * These fields are used to avoid having to increment corlib versions
                 * when a new field is added to the unmanaged MonoThread structure.
                 */
+               private IntPtr unused1;
                private IntPtr unused2;
+
+               /* This is used only to check that we are in sync between the representation
+                * of MonoInternalThread in native and InternalThread in managed
+                *
+                * DO NOT RENAME! DO NOT ADD FIELDS AFTER! */
+               private IntPtr last;
                #endregion
 #pragma warning restore 169, 414, 649
 
                // Closes the system thread handle
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private extern void Thread_free_internal(IntPtr handle);
+               private extern void Thread_free_internal();
 
                [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
                ~InternalThread() {
-                       Thread_free_internal(system_thread_handle);
+                       Thread_free_internal();
                }
        }
 
@@ -116,7 +121,6 @@ namespace System.Threading {
                private InternalThread internal_thread;
                object m_ThreadStartArg;
                object pending_exception;
-               int priority = (int) ThreadPriority.Normal;
                #endregion
 #pragma warning restore 414
 
@@ -278,17 +282,17 @@ namespace System.Threading {
                        }
                }
 
-               // Looks up the object associated with the current thread
-               // this is called by the JIT directly, too
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               private extern static InternalThread CurrentInternalThread_internal();
+               private extern static Thread GetCurrentThread ();
 
                public static Thread CurrentThread {
                        [ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
                        get {
-                               if (current_thread == null)
-                                       current_thread = new Thread (CurrentInternalThread_internal ());
-                               return current_thread;
+                               Thread current = current_thread;
+                               if (current != null)
+                                       return current;
+                               // This will set the current_thread tls variable
+                               return GetCurrentThread ();
                        }
                }
 
@@ -453,6 +457,12 @@ namespace System.Threading {
                {
                        throw new PlatformNotSupportedException ("Thread.ResetAbort is not supported on the current platform.");
                }
+
+               internal object AbortReason {
+                       get {
+                               throw new PlatformNotSupportedException ("Thread.ResetAbort is not supported on the current platform.");
+                       }
+               }
 #endif // MONO_FEATURE_THREAD_ABORT
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
@@ -697,5 +707,10 @@ namespace System.Threading {
                        throw new PlatformNotSupportedException ("Thread.Resume is not supported on the current platform.");
                }
 #endif
+
+               public void DisableComObjectEagerCleanup ()
+               {
+                       throw new PlatformNotSupportedException ();
+               }
        }
 }