/*========================================================================= ** 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)); }
/*========================================================================= ** 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. ** =========================================================================*/ /// <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); }
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); }
/*========================================================================= ** 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); }
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; }
public static void FreeNamedDataSlot(string name) { lock (datastore_lock) { if (datastorehash == null) { InitDataStoreHash(); } LocalDataStoreSlot slot = (LocalDataStoreSlot)datastorehash [name]; if (slot != null) { datastorehash.Remove(slot); } } }
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); } }
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); } }
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); } }
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; }
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); } }
public static void SetData(LocalDataStoreSlot slot, object data) => LocalDataStore.SetData(slot, data);
public static object GetData(LocalDataStoreSlot slot) => LocalDataStore.GetData(slot);
// 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) { }
public static unsafe void SetData(LocalDataStoreSlot slot, object data) { var value = Intrinsic.GetObjectAddress(data); SetThreadLocalStorage(slot.Position, (void *)value); }
/// <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(); }
public TLSHolder() { this.m_slot = Thread.AllocateDataSlot(); }
// Free a named data store slot. public static void FreeNamedDataSlot(String name) { LocalDataStoreSlot.FreeNamed(name); }
public static unsafe object GetData(LocalDataStoreSlot slot) { var value = GetThreadLocalStorage(slot.Position); return(Intrinsic.GetObjectFromAddress((Pointer)value)); }
public static object GetData(LocalDataStoreSlot slot) { return(GetThreadLocal(slot).Value); }
public static void SetData(LocalDataStoreSlot slot, object value) { GetThreadLocal(slot).Value = value; }
/// <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(); }