Author: zoltan
Date: 2005-03-10 11:23:50 -0500 (Thu, 10 Mar 2005)
New Revision: 41651

Modified:
   trunk/mcs/class/corlib/System.Threading/ChangeLog
   trunk/mcs/class/corlib/System.Threading/Thread.cs
Log:
2005-03-10  Zoltan Varga  <[EMAIL PROTECTED]>

        * Thread.cs: Make slothash a ThreadStatic field. Fixes #65414.


Modified: trunk/mcs/class/corlib/System.Threading/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Threading/ChangeLog   2005-03-10 16:19:02 UTC 
(rev 41650)
+++ trunk/mcs/class/corlib/System.Threading/ChangeLog   2005-03-10 16:23:50 UTC 
(rev 41651)
@@ -1,3 +1,7 @@
+2005-03-10  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * Thread.cs: Make slothash a ThreadStatic field. Fixes #65414.
+
 2005-02-21  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * Monitor.cs Interlocked.cs: Add net 2.0 ReliabilityContractAttributes.

Modified: trunk/mcs/class/corlib/System.Threading/Thread.cs
===================================================================
--- trunk/mcs/class/corlib/System.Threading/Thread.cs   2005-03-10 16:19:02 UTC 
(rev 41650)
+++ trunk/mcs/class/corlib/System.Threading/Thread.cs   2005-03-10 16:23:50 UTC 
(rev 41651)
@@ -76,7 +76,6 @@
                private IntPtr static_data;
                private IntPtr jit_data;
                private IntPtr lock_data;
-               Hashtable slothash;
                Context current_appcontext;
                int stack_size;
                object start_obj;
@@ -91,6 +90,9 @@
                private int serialized_ui_culture_info_len;
                #endregion
 
+               [ThreadStatic] 
+               static Hashtable slothash;
+
                // can be both a ThreadSart and a ParameterizedThreadStart
                private MulticastDelegate threadstart;
                private string thread_name=null;
@@ -144,35 +146,6 @@
                        }
                }
 
-               private static Hashtable GetTLSSlotHash() {
-                       Thread t = CurrentThread;
-                       if (t.slothash == null) {
-                               // Not synchronised, because this is
-                               // thread specific anyway.
-                               t.slothash = new Hashtable ();
-                       }
-
-                       return t.slothash;
-               }
-               
-               internal static object ResetDataStoreStatus () {
-                       Thread t = CurrentThread;
-                       Hashtable slothash = t.slothash;
-                       t.slothash = null;
-                       return slothash;
-               }
-
-               internal static void RestoreDataStoreStatus (object data) {
-                       Thread t = CurrentThread;
-                       t.slothash = ((Hashtable)data);
-               }
-
-               public static LocalDataStoreSlot AllocateDataSlot() {
-                       LocalDataStoreSlot slot = new LocalDataStoreSlot();
-
-                       return(slot);
-               }
-
                // Stores a hash keyed by strings of LocalDataStoreSlot objects
                static Hashtable datastorehash;
                private static object datastore_lock = new object ();
@@ -216,11 +189,27 @@
                        }
                }
 
+               private static Hashtable SlotHash {
+                       get {
+                               if (slothash == null)
+                                       slothash = new Hashtable ();
+                               return slothash;
+                       }
+               }
+
+               public static LocalDataStoreSlot AllocateDataSlot() {
+                       return new LocalDataStoreSlot();
+               }
+
                public static object GetData(LocalDataStoreSlot slot) {
-                       Hashtable slothash=GetTLSSlotHash();
-                       return(slothash[slot]);
+                       return SlotHash [slot];
                }
 
+               public static void SetData(LocalDataStoreSlot slot,
+                                          object data) {
+                       SlotHash [slot] = data;
+               }
+
                public static AppDomain GetDomain() {
                        return AppDomain.CurrentDomain;
                }
@@ -250,19 +239,7 @@
                {
                        ResetAbort_internal ();
                }
-               
 
-               public static void SetData(LocalDataStoreSlot slot,
-                                          object data) {
-                       Hashtable slothash=GetTLSSlotHash();
-
-                       if(slothash.Contains(slot)) {
-                               slothash.Remove(slot);
-                       }
-                       
-                       slothash.Add(slot, data);
-               }
-
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                private extern static void Sleep_internal(int ms);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to