示例#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));
        }
示例#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));
        }
示例#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);
        }
示例#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);
 }
示例#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);
        }
示例#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;
        }
示例#7
0
文件: Thread.cs 项目: kienlt91/mono
        public static void FreeNamedDataSlot(string name)
        {
            lock (datastore_lock) {
                if (datastorehash == null)
                {
                    InitDataStoreHash();
                }
                LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash [name];

                if (slot != null)
                {
                    datastorehash.Remove(slot);
                }
            }
        }
示例#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);
            }
        }
示例#9
0
文件: Thread.cs 项目: kienlt91/mono
        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);
            }
        }
示例#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);
            }
        }
示例#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;
 }
示例#12
0
文件: Thread.cs 项目: kienlt91/mono
        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);
            }
        }
示例#13
0
 public static void SetData(LocalDataStoreSlot slot, object data) => LocalDataStore.SetData(slot, data);
示例#14
0
 public static object GetData(LocalDataStoreSlot slot) => LocalDataStore.GetData(slot);
示例#15
0
文件: Thread.cs 项目: ForNeVeR/pnet
 // 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)
 {
 }
示例#18
0
文件: Thread.cs 项目: djlw78/abanu
        public static unsafe void SetData(LocalDataStoreSlot slot, object data)
        {
            var value = Intrinsic.GetObjectAddress(data);

            SetThreadLocalStorage(slot.Position, (void *)value);
        }
示例#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();
 }
示例#20
0
 public TLSHolder()
 {
     this.m_slot = Thread.AllocateDataSlot();
 }
示例#21
0
文件: Thread.cs 项目: ForNeVeR/pnet
 // Free a named data store slot.
 public static void FreeNamedDataSlot(String name)
 {
     LocalDataStoreSlot.FreeNamed(name);
 }
示例#22
0
文件: Thread.cs 项目: djlw78/abanu
        public static unsafe object GetData(LocalDataStoreSlot slot)
        {
            var value = GetThreadLocalStorage(slot.Position);

            return(Intrinsic.GetObjectFromAddress((Pointer)value));
        }
示例#23
0
 public static object GetData(LocalDataStoreSlot slot)
 {
     return(GetThreadLocal(slot).Value);
 }
示例#24
0
 public static void SetData(LocalDataStoreSlot slot, object value)
 {
     GetThreadLocal(slot).Value = value;
 }
示例#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();
 }