Exemple #1
0
        /*=========================================================================
        ** Retrieves the value from the specified slot on the current thread, for that thread's current domain.
        ** =========================================================================*/
        /// <include file='doc\Thread.uex' path='docs/doc[@for="Thread.GetData"]/*' />
        public static Object GetData(LocalDataStoreSlot slot)
        {
            m_LocalDataStoreMgr.ValidateSlot(slot);

            LocalDataStore dls = GetDomainLocalStore();

            if (dls == null)
            {
                return(null);
            }

            return(dls.GetData(slot));
        }
Exemple #2
0
        /*=========================================================================
        ** 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));
        }
Exemple #3
0
        /*=========================================================================
        ** Sets the data in the specified slot on the currently running thread, for that thread's current domain.
        ** =========================================================================*/
        /// <include file='doc\Thread.uex' path='docs/doc[@for="Thread.SetData"]/*' />
        public static void SetData(LocalDataStoreSlot slot, Object data)
        {
            LocalDataStore dls = GetDomainLocalStore();

            // Create new DLS if one hasn't been created for this domain for this thread
            if (dls == null)
            {
                dls = m_LocalDataStoreMgr.CreateLocalDataStore();
                SetDomainLocalStore(dls);
            }

            dls.SetData(slot, data);
        }
Exemple #4
0
 public static object GetData(LocalDataStoreSlot slot)
 {
     object[] slots = local_slots;
     if (slot == null)
     {
         throw new ArgumentNullException("slot");
     }
     if (slots != null && slot.slot < slots.Length)
     {
         return(slots [slot.slot]);
     }
     return(null);
 }
Exemple #5
0
        /*=========================================================================
        ** 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);
        }
Exemple #6
0
        private ThreadLocal(Func <T> valueFactory, bool initCachedException)
        {
            if (initCachedException)
            {
                cachedException = new ThreadLocal <Exception>(ThreadLocal <Exception> .InitDefault, false);
            }

            if (valueFactory == null)
            {
                throw new ArgumentNullException("valueFactory");
            }

            localStore        = Thread.AllocateDataSlot();
            this.valueFactory = valueFactory;
        }
Exemple #7
0
        public static void FreeNamedDataSlot(string name)
        {
            lock (datastore_lock) {
                if (datastorehash == null)
                {
                    InitDataStoreHash();
                }
                LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash [name];

                if (slot != null)
                {
                    datastorehash.Remove(slot);
                }
            }
        }
Exemple #8
0
        public LocalDataStoreSlot Get(string name)
        {
            lock (this) {
                if (datastorehash == null)
                {
                    datastorehash = new Dictionary <string, LocalDataStoreSlot> ();
                }

                LocalDataStoreSlot slot;
                if (!datastorehash.TryGetValue(name, out slot))
                {
                    slot = new LocalDataStoreSlot(true);
                }

                return(slot);
            }
        }
Exemple #9
0
        public static LocalDataStoreSlot GetNamedDataSlot(string name)
        {
            lock (datastore_lock) {
                if (datastorehash == null)
                {
                    InitDataStoreHash();
                }
                LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash[name];

                if (slot == null)
                {
                    slot = AllocateNamedDataSlot(name);
                }

                return(slot);
            }
        }
Exemple #10
0
        public LocalDataStoreSlot Allocate(string name)
        {
            lock (this) {
                if (datastorehash == null)
                {
                    datastorehash = new Dictionary <string, LocalDataStoreSlot> ();
                }

                if (datastorehash.ContainsKey(name))
                {
                    // This exception isnt documented (of
                    // course) but .net throws it
                    throw new ArgumentException("Named data slot already added");
                }

                var slot = new LocalDataStoreSlot(thread_local);
                datastorehash.Add(name, slot);
                return(slot);
            }
        }
Exemple #11
0
 public static void SetData(LocalDataStoreSlot slot, object data)
 {
     object[] slots = local_slots;
     if (slot == null)
     {
         throw new ArgumentNullException("slot");
     }
     if (slots == null)
     {
         slots       = new object [slot.slot + 2];
         local_slots = slots;
     }
     else if (slot.slot >= slots.Length)
     {
         object[] nslots = new object [slot.slot + 2];
         slots.CopyTo(nslots, 0);
         slots       = nslots;
         local_slots = slots;
     }
     slots [slot.slot] = data;
 }
Exemple #12
0
        public static LocalDataStoreSlot AllocateNamedDataSlot(string name)
        {
            lock (datastore_lock) {
                if (datastorehash == null)
                {
                    InitDataStoreHash();
                }
                LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash [name];
                if (slot != null)
                {
                    // This exception isnt documented (of
                    // course) but .net throws it
                    throw new ArgumentException("Named data slot already added");
                }

                slot = AllocateDataSlot();

                datastorehash.Add(name, slot);

                return(slot);
            }
        }
Exemple #13
0
 public static void SetData(LocalDataStoreSlot slot, object data) => LocalDataStore.SetData(slot, data);
Exemple #14
0
 public static object GetData(LocalDataStoreSlot slot) => LocalDataStore.GetData(slot);
Exemple #15
0
 // Get a previously allocated named data store slot.
 public static LocalDataStoreSlot GetNamedDataSlot(String name)
 {
     return(LocalDataStoreSlot.GetNamed(name));
 }
 public static object GetData(LocalDataStoreSlot slot)
 {
     return(default(object));
 }
 public static void SetData(LocalDataStoreSlot slot, object data)
 {
 }
Exemple #18
0
        public static unsafe void SetData(LocalDataStoreSlot slot, object data)
        {
            var value = Intrinsic.GetObjectAddress(data);

            SetThreadLocalStorage(slot.Position, (void *)value);
        }
Exemple #19
0
 /// <summary>Sets the data in the specified slot on the currently running thread, for that thread's current domain. For better performance, use fields marked with the <see cref="T:System.ThreadStaticAttribute" /> attribute instead.</summary><param name="slot">The <see cref="T:System.LocalDataStoreSlot" /> in which to set the value. </param><param name="data">The value to be set. </param><filterpriority>1</filterpriority>
 public static void SetData(LocalDataStoreSlot slot, object data)
 {
     throw new NotImplementedException();
 }
Exemple #20
0
 public TLSHolder()
 {
     this.m_slot = Thread.AllocateDataSlot();
 }
Exemple #21
0
 // Free a named data store slot.
 public static void FreeNamedDataSlot(String name)
 {
     LocalDataStoreSlot.FreeNamed(name);
 }
Exemple #22
0
        public static unsafe object GetData(LocalDataStoreSlot slot)
        {
            var value = GetThreadLocalStorage(slot.Position);

            return(Intrinsic.GetObjectFromAddress((Pointer)value));
        }
Exemple #23
0
 public static object GetData(LocalDataStoreSlot slot)
 {
     return(GetThreadLocal(slot).Value);
 }
Exemple #24
0
 public static void SetData(LocalDataStoreSlot slot, object value)
 {
     GetThreadLocal(slot).Value = value;
 }
Exemple #25
0
 /// <summary>Retrieves the value from the specified slot on the current thread, within the current thread's current domain. For better performance, use fields that are marked with the <see cref="T:System.ThreadStaticAttribute" /> attribute instead.</summary><returns>The retrieved value.</returns><param name="slot">The <see cref="T:System.LocalDataStoreSlot" /> from which to get the value. </param><filterpriority>2</filterpriority>
 public static object GetData(LocalDataStoreSlot slot)
 {
     throw new NotImplementedException();
 }