public static int Main () { Console.WriteLine ("Hello, World!"); Test test=new Test(); Thread thr=new Thread(new ThreadStart(test.Thread_func)); thr.Start(); for(int i=0; i<51200; i++) { slot[i]=Thread.AllocateDataSlot(); Thread.SetData(slot[i], i); } Thread.SetData(slot[11111], 69); Thread.SetData(slot[26801], 69); Thread.Sleep(10000); Console.WriteLine("Main thread done"); Console.WriteLine("slot 11111 contains " + Thread.GetData(slot[11111])); Console.WriteLine("slot 16801 contains " + Thread.GetData(slot[16801])); Console.WriteLine("slot 26801 contains " + Thread.GetData(slot[26801])); Console.WriteLine("slot 76801 contains " + Thread.GetData(slot[76801])); // Test appdomain transitions AppDomain ad = AppDomain.CreateDomain ("MyFriendlyDomain"); Test o = (Test) ad.CreateInstanceFromAndUnwrap ("dataslot.exe", "Test"); slot2 = Thread.AllocateDataSlot (); Thread.SetData (slot2, "hello"); o.Foo (AppDomain.CurrentDomain); if (Test.slot_value != "hello") return 1; return 0; }
internal static HybridDictionary GetGlobalContext() { if (HttpContext.Current == null) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_globalContextName); return((HybridDictionary)Thread.GetData(slot)); } else { return((HybridDictionary)HttpContext.Current.Items[_globalContextName]); } }
internal static void SetGlobalContext(HybridDictionary globalContext) { if (HttpContext.Current == null) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot("Dothan.GlobalContext"); Thread.SetData(slot, globalContext); } else { HttpContext.Current.Items["Dothan.GlobalContext"] = globalContext; } }
public static void SetGlobalContext(HybridDictionary globalContext) { if (HttpContext.Current == null) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_globalContextName); Thread.SetData(slot, globalContext); } else { HttpContext.Current.Items[_globalContextName] = globalContext; } }
LocalDataStoreSlot writeCache; // thread-local write copy public STMObject(ICloneable obj, LocalDataStoreSlot readCache, LocalDataStoreSlot writeCache) { start = new Locator(obj); this.readCache = readCache; this.writeCache = writeCache; // Do not cache objects if not in transaction! if (Xaction.IsActive) { Xaction.AddToCache(readCache, obj); Xaction.AddToCache(writeCache, obj); } }
/// <summary> /// The authenticated token is extracted from TLS(Thread Local Storage) /// from the named data slot 'AuthenticatedToken'. /// </summary> /// <returns>The <see cref="AuthenticatedToken"/> corresponding to the identity that has been /// authenticated.</returns> private static AuthenticatedToken GetTokenFromThreadLocalStorage() { try { LocalDataStoreSlot slot = Thread.GetNamedDataSlot("AuthenticatedToken"); return(Thread.GetData(slot) as AuthenticatedToken); } catch { throw new AuthorizationException(Zentity.Security.Authorization.Properties.Resources.TokenUnavailableInTLS); } }
/// <summary> /// Gets the client context. /// </summary> /// <returns></returns> public ContextDictionary GetClientContext() { if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) { return((ContextDictionary)AppDomain.CurrentDomain.GetData(_clientContextName)); } else { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_clientContextName); return((ContextDictionary)Thread.GetData(slot)); } }
private bool GetThreadDataValueAsBool(string propertyName) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(propertyName); object dataSlot = Thread.GetData(slot); if (dataSlot != null) { return((bool)dataSlot); } return(false); }
private string GetThreadDataValue(string propertyName) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(propertyName); object dataSlot = Thread.GetData(slot); if (dataSlot != null) { return(dataSlot.ToString()); } return(string.Empty); }
private static void SetClientContext(HybridDictionary clientContext) { if (HttpContext.Current == null) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot("Dothan.ClientContext"); Thread.SetData(slot, clientContext); } else { HttpContext.Current.Items["Dothan.ClientContext"] = clientContext; } }
internal static HybridDictionary GetClientContext() { if (HttpContext.Current == null) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot("Dothan.ClientContext"); return((HybridDictionary)Thread.GetData(slot)); } else { return((HybridDictionary)HttpContext.Current.Items["Dothan.ClientContext"]); } }
/// <summary> /// Sets the client context. /// </summary> /// <param name="clientContext">Client context.</param> public void SetClientContext(ContextDictionary clientContext) { if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) { AppDomain.CurrentDomain.SetData(_clientContextName, clientContext); } else { LocalDataStoreSlot slot = Thread.GetNamedDataSlot(_clientContextName); Thread.SetData(slot, clientContext); } }
static void Main(string[] args) { Factory.CreateObject(); UserSession us = new UserSession(); us.UserID = SS.DB.Query.ParameterServices.ImportSystemUserID; us.CurrentProgramCode = "ImageFileIO"; LocalDataStoreSlot slot = System.Threading.Thread.AllocateNamedDataSlot(SessionEnum.WebSession.UserProfiles.ToString()); System.Threading.Thread.SetData(slot, us); imagePostService = Factory.DbDocumentImagePostingService; avDocumentService = Factory.AvAdvanceDocumentService; expDocumentService = Factory.FnExpenseDocumentService; avDocumentQuery = Factory.AvAdvanceDocumentQuery; expDocumentQuery = Factory.FnExpenseDocumentQuery; docQuery = Factory.SCGDocumentQuery; imgLogService = Factory.SuImageToSAPLogService; parameterQuery = Factory.DbParameterQuery; imgPostingQuery = Factory.DbDocumentImagePostingQuery; fnRemittanceQuery = Factory.FnRemittanceQuery; docService = Factory.SCGDocumentService; Console.WriteLine("Program Export Document Image is running."); Factory.CreateObject(); if (args.Length == 0) { args = new string[1]; Console.WriteLine("Insert \"I\" or \"O\" to import / export mode"); args[0] = Console.ReadLine(); } if (args[0].ToLower() == "i") { Console.WriteLine("Import Start."); ImportPath = args[1]; ReadExportImageLogfile(); } if (args[0].ToLower() == "o") { Console.WriteLine("Export Start."); RootPath = args[1]; ExportImagePath = args[2]; ExportDocumentImage(); } Console.WriteLine("Program finish."); }
public TestBase(string strName, int nDeviceID = DEFAULT_DEVICE_ID, EngineParameter.Engine engine = EngineParameter.Engine.DEFAULT, object tag = null, bool bHalf = false) { m_bHalf = bHalf; // If an auto test has set the GPUID, us it instead. LocalDataStoreSlot lds = Thread.GetNamedDataSlot("GPUID"); if (lds != null) { object obj = Thread.GetData(lds); if (obj != null) { string strGpuId = obj.ToString(); if (!string.IsNullOrEmpty(strGpuId)) { int nVal; if (int.TryParse(strGpuId, out nVal) && nDeviceID < 4) { nDeviceID = nVal; } } } } m_strName = strName; if (create_count == 1) { m_rgTests.Add(create(DataType.FLOAT, strName, nDeviceID, engine)); m_rgTests.Add(create(DataType.DOUBLE, strName, nDeviceID, engine)); } else { for (int i = 0; i < create_count; i++) { ITest iTestF = create(i, DataType.FLOAT, strName, nDeviceID, engine); if (iTestF != null) { m_rgTests.Add(iTestF); } ITest iTestD = create(i, DataType.DOUBLE, strName, nDeviceID, engine); if (iTestD != null) { m_rgTests.Add(iTestD); } } } }
// Token: 0x060006DA RID: 1754 RVA: 0x0001AECC File Offset: 0x000190CC public static TStream GetCurrent <TStream>() where TStream : BufferStream, new() { LocalDataStoreSlot namedDataSlot = Thread.GetNamedDataSlot("ThreadBufferListStream"); TStream tstream = Thread.GetData(namedDataSlot) as TStream; if (tstream != null) { return(tstream); } tstream = Activator.CreateInstance <TStream>(); Thread.SetData(namedDataSlot, tstream); return(tstream); }
public void Error(Exception e) { LocalDataStoreSlot sessionIDSlot = Thread.GetNamedDataSlot("sessionID"); var logger = LogManager.GetLogger("error"); var logEvent = new LogEventInfo(); logEvent.Level = LogLevel.Error; logEvent.LoggerName = "error"; logEvent.Message = e.ToString(); logEvent.Properties["SessionID"] = Thread.GetData(sessionIDSlot); logger.Log(logEvent); }
public static object GetData(LocalDataStoreSlot slot) { Context ctx = Thread.CurrentContext; lock (ctx) { if (ctx.datastore != null && slot.slot < ctx.datastore.Length) { return(ctx.datastore [slot.slot]); } return(null); } }
/// <summary>Allocates a named data slot.</summary> /// <returns>A local data slot object.</returns> /// <param name="name">The required name for the data slot. </param> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static LocalDataStoreSlot AllocateNamedDataSlot(string name) { object syncRoot = Context.namedSlots.SyncRoot; LocalDataStoreSlot result; lock (syncRoot) { LocalDataStoreSlot localDataStoreSlot = Context.AllocateDataSlot(); Context.namedSlots.Add(name, localDataStoreSlot); result = localDataStoreSlot; } return(result); }
void CheckOtherContextDatastore() { LocalDataStoreSlot namedSlot1 = Context.GetNamedDataSlot("slot1"); LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot("slot2"); Assert.IsTrue(Context.GetData(slot) == null, "Slot already has data"); Assert.IsTrue(Context.GetData(namedSlot1) == null, "Slot already has data"); Assert.IsTrue(Context.GetData(namedSlot2) == null, "Slot already has data"); Context.SetData(slot, "other data"); Context.SetData(namedSlot1, "other data1"); Context.SetData(namedSlot2, "other data2"); }
/// <summary> /// 激活会话 /// </summary> /// <param name="sessionId">The session id.</param> public void Activate(string sessionId) { if (!sessions.ContainsKey(sessionId)) { logger.Debug(String.Format("不存在 [{0}] 的会话, 该会话可能已经超时无法激活此会话.", sessionId)); return; } LocalDataStoreSlot slot = Thread.GetNamedDataSlot(SESSION_SOLOTNAME); Thread.SetData(slot, sessionId); sessions[sessionId].Activate(); }
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); }
// GET: Producto public ActionResult Index() { local = Thread.GetNamedDataSlot("tenant"); string valor_Tenant = System.Threading.Thread.GetData(local).ToString(); var user = Session["usuario"] as UsuarioSite; var lista_Productos = _blproducto.ObtenerProductos(); ViewBag.ListaCategorias = lista_Productos; return(View()); }
public static IUnitOfWork UnitOfWork() { lock (unitOfWorkGetLock) { LocalDataStoreSlot lds = System.Threading.Thread.GetNamedDataSlot("" + System.Threading.Thread.CurrentThread.ManagedThreadId); var unitOfWork = (IUnitOfWork)System.Threading.Thread.GetData(lds); if (unitOfWork == null) { throw new Exception("A unit of work has not been started for the current thread."); } return(unitOfWork); } }
public static Guid GetTenant() { lock (tenantGetLock) { LocalDataStoreSlot lds = System.Threading.Thread.GetNamedDataSlot("Tenant" + System.Threading.Thread.CurrentThread.ManagedThreadId); var tenantGuid = (Guid)System.Threading.Thread.GetData(lds); if (tenantGuid == null) { throw new Exception("A tenant has not been set for the current thread."); } return(tenantGuid); } }
public static TStream GetCurrent <TStream>() where TStream : BufferStream, new() { LocalDataStoreSlot namedDataSlot = Thread.GetNamedDataSlot("ThreadBufferListStream"); TStream val = Thread.GetData(namedDataSlot) as TStream; if (val != null) { return(val); } val = new TStream(); Thread.SetData(namedDataSlot, val); return(val); }
public void invoke(object obj) { m_taskStatus = Task.Factory.StartNew(new Action(status)); Tuple <object, int> arg = obj as Tuple <object, int>; object instance = arg.Item1; int nGpuId = arg.Item2; try { LocalDataStoreSlot lds = Thread.GetNamedDataSlot("GPUID"); if (lds == null) { lds = Thread.AllocateNamedDataSlot("GPUID"); } if (lds != null) { Thread.SetData(lds, nGpuId.ToString()); } m_swTiming.Reset(); m_swTiming.Start(); m_status = STATUS.Running; m_mi.Invoke(instance, null); m_status = STATUS.Passed; } catch (Exception excpt) { if (excpt.Message == "Aborted!" || (excpt.InnerException != null && excpt.InnerException.Message == "Aborted!")) { m_status = STATUS.Aborted; } else { m_status = STATUS.Failed; m_errorInfo.SetError(excpt); } } finally { m_swTiming.Stop(); if (m_miDispose != null) { m_miDispose.Invoke(instance, null); } m_evtStatusCancel.Set(); Thread.FreeNamedDataSlot("GPUID"); } }
/// <summary> /// Gets the data for a slot in thread-local storage. /// </summary> /// <typeparam name="T">Type of the data.</typeparam> /// <param name="slot">The slot to get data for.</param> /// <param name="create">Automatically create the object if it doesn't exist.</param> /// <returns> /// Slot data (will create T if null). /// </returns> public static T GetDataForSlot <T>(object slot, bool create = true) where T : class, new() { #if TLS_WORKAROUND IDictionary <int, object> dict = GetThreadDataDictionary(Thread.CurrentThread); int slotNumber = (int)slot; object v; if (!dict.TryGetValue(slotNumber, out v)) { if (!create) { return(null); } v = new T(); dict.Add(slotNumber, v); } return((T)v); #elif NETSTANDARD || NET4_6 var thread = slot as ThreadLocal <object>; if (thread == null) { throw new InvalidOperationException($"Expected ThreadLocal object. Received {slot?.GetType()}."); } if (!thread.IsValueCreated) { if (!create) { return(null); } thread.Value = new T(); } return((T)thread.Value); #else LocalDataStoreSlot localDataStoreSlot = (LocalDataStoreSlot)slot; object v = Thread.GetData(localDataStoreSlot); if (v == null) { if (!create) { return(null); } v = new T(); Thread.SetData(localDataStoreSlot, v); } return((T)v); #endif }
public static object GetData(LocalDataStoreSlot slot) { if (_ctypeThreadType == null) { return(null); } if (_delGetData == null) { _delGetData = CDelegateEx.CreateDelegate <DelGetData> (_ctypeThread, "GetData"); } return(_delGetData(slot)); }
/// <summary> /// Get an instance of T for current thread /// </summary> /// <param name="appendedkey"></param> /// <param name="onCreateInstance"></param> /// <returns></returns> public static T GetThreadInstance(string appendedkey, CreateInstanceHandler <T> onCreateInstance) { LocalDataStoreSlot slot = Thread.GetNamedDataSlot("__ThreadInstanceTable"); Dictionary <string, object> instances = Thread.GetData(slot) as Dictionary <string, object>; if (instances == null) { lock (LockKey) { instances = Thread.GetData(slot) as Dictionary <string, object>; if (instances == null) { instances = new Dictionary <string, object>(); Thread.SetData(slot, instances); } } } string key = string.Format("{0}:{1}", typeof(T).AssemblyQualifiedName, appendedkey); object obj; if (instances.TryGetValue(key, out obj)) { return((T)obj); } else { lock (LockKey) { if (instances.TryGetValue(key, out obj)) { return((T)obj); } else { T t; try { t = (onCreateInstance == null ? Activator.CreateInstance <T>() : onCreateInstance()); } catch { t = default(T); } instances[key] = t; return(t); } } } }
/// <summary> /// Release the instance of T for current thread /// </summary> public static void ReleaseThreadInstance() { LocalDataStoreSlot slot = Thread.GetNamedDataSlot("__ThreadInstanceTable"); lock (LockKey) { Dictionary <int, object> instances = Thread.GetData(slot) as Dictionary <int, object>; if (instances != null) { int threadId = Thread.CurrentThread.ManagedThreadId; instances.Remove(threadId); } } }
public static void SetData(LocalDataStoreSlot slot, object data) { if (_ctypeThreadType == null) { return; } if (_delSetData == null) { _delSetData = CDelegateEx.CreateDelegate <DelSetData> (_ctypeThread, "SetData"); } _delSetData(slot, data); }
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 int Main () { Console.WriteLine ("Hello, World!"); slot=Thread.AllocateDataSlot(); LocalDataStoreSlot namedslot=Thread.AllocateNamedDataSlot("data-slot"); Test test = new Test(); Thread thr=new Thread(new ThreadStart(test.Thread_func)); thr.Start(); Thread.Sleep(1000); Thread main=Thread.CurrentThread; main.Name="wibble"; Thread othermain=Thread.CurrentThread; Console.WriteLine("Other name " + othermain.Name); Thread.Sleep(0); Console.WriteLine("In the main line!"); Console.WriteLine("Trying to enter lock"); if(Monitor.TryEnter(thr, 100)==true) { Console.WriteLine("Returned lock"); Monitor.Exit(thr); } else { Console.WriteLine("Didn't get lock"); } Thread.SetData(slot, main); Thread storedthr=(Thread)Thread.GetData(slot); Console.WriteLine("Stored subthread is " + storedthr.Name); Thread.SetData(namedslot, main); storedthr=(Thread)Thread.GetData(namedslot); Console.WriteLine("Stored subthread is " + storedthr.Name); if(thr.Join(5000)) { Console.WriteLine("Joined thread"); } else { Console.WriteLine("Didn't join thread"); } lock(thr) { Monitor.Pulse(thr); Console.WriteLine("Signalled thread"); } thr.Join(); return 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 (true); datastorehash.Add (name, slot); return slot; } }
// Get a data store slot with a specific name. internal static LocalDataStoreSlot GetNamed(String name) { lock(typeof(LocalDataStoreSlot)) { LocalDataStoreSlot slot = namedSlots; while(slot != null) { if(slot.isNamed && slot.name == name) { return slot; } slot = slot.nextNamed; } slot = new LocalDataStoreSlot(true, name); slot.nextNamed = namedSlots; namedSlots = slot; return slot; } }
// Set the value of a local data store slot. public static void SetData(LocalDataStoreSlot slot, Object value) { Thread.SetData(slot, value); }
private static BaseLoggingObject LoggingInitialize() { #if DEBUG if (GetSwitchValue("SystemNetLogging", "System.Net logging module", false) && GetSwitchValue("SystemNetLog_ConnectionMonitor", "System.Net connection monitor thread", false)) { InitConnectionMonitor(); } #endif // DEBUG #if TRAVE // by default we'll log to c:\temp\ so that non interactive services (like w3wp.exe) that don't have environment // variables can easily be debugged, note that the ACLs of the directory might need to be adjusted if (!GetSwitchValue("SystemNetLog_OverrideDefaults", "System.Net log override default settings", false)) { s_ThreadIdSlot = Thread.AllocateDataSlot(); s_UseThreadId = true; s_UseTimeSpan = true; s_DumpWebData = true; s_MaxDumpSize = 256; s_UsePerfCounter = true; s_DebugCallNesting = true; s_DumpToConsole = false; s_RootDirectory = "C:\\Temp\\"; return new LoggingObject(); } if (GetSwitchValue("SystemNetLogging", "System.Net logging module", false)) { s_ThreadIdSlot = Thread.AllocateDataSlot(); s_UseThreadId = GetSwitchValue("SystemNetLog_UseThreadId", "System.Net log display system thread id", false); s_UseTimeSpan = GetSwitchValue("SystemNetLog_UseTimeSpan", "System.Net log display ticks as TimeSpan", false); s_DumpWebData = GetSwitchValue("SystemNetLog_DumpWebData", "System.Net log display HTTP send/receive data", false); s_MaxDumpSize = GetSwitchValue("SystemNetLog_MaxDumpSize", "System.Net log max size of display data", 256); s_UsePerfCounter = GetSwitchValue("SystemNetLog_UsePerfCounter", "System.Net log use QueryPerformanceCounter() to get ticks ", false); s_DebugCallNesting = GetSwitchValue("SystemNetLog_DebugCallNesting", "System.Net used to debug call nesting", false); s_DumpToConsole = GetSwitchValue("SystemNetLog_DumpToConsole", "System.Net log to console", false); s_RootDirectory = GetSwitchValue("SystemNetLog_RootDirectory", "System.Net root directory of log file", string.Empty); return new LoggingObject(); } #endif // TRAVE return new BaseLoggingObject(); }
public static object GetData (LocalDataStoreSlot slot) { Context ctx = Thread.CurrentContext; lock (ctx) { if (ctx.datastore != null && slot.slot < ctx.datastore.Length) return ctx.datastore [slot.slot]; return null; } }
public static void SetData (LocalDataStoreSlot slot, object data) { Context ctx = Thread.CurrentContext; lock (ctx) { if (ctx.datastore == null) { ctx.datastore = new object [slot.slot + 2]; } else if (slot.slot >= ctx.datastore.Length) { object[] nslots = new object [slot.slot + 2]; ctx.datastore.CopyTo (nslots, 0); ctx.datastore = nslots; } ctx.datastore [slot.slot] = data; } }
public static object GetData (LocalDataStoreSlot slot) { return Thread.CurrentContext.MyLocalStore.GetData (slot); }
// Get the data stored in a particular data store slot. public static Object GetData(LocalDataStoreSlot slot) { return Thread.GetData(slot); }
// Set the data in a particular local data store slot. public static void SetData(LocalDataStoreSlot slot, Object data) { if(slot != null) { slot.Data = data; } }
private static void VerifyLocalDataSlot(LocalDataStoreSlot slot) { Assert.NotNull(slot); var waitForThreadArray = new Action[2]; var threadArray = new Thread[2]; var barrier = new Barrier(threadArray.Length); var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; Func<bool> barrierSignalAndWait = () => { try { Assert.True(barrier.SignalAndWait(UnexpectedTimeoutMilliseconds, cancellationToken)); } catch (OperationCanceledException) { return false; } return true; }; Action<int> threadMain = threadIndex => { try { Assert.Null(Thread.GetData(slot)); if (!barrierSignalAndWait()) { return; } if (threadIndex == 0) { Thread.SetData(slot, threadIndex); } if (!barrierSignalAndWait()) { return; } if (threadIndex == 0) { Assert.Equal(threadIndex, Thread.GetData(slot)); } else { Assert.Null(Thread.GetData(slot)); } if (!barrierSignalAndWait()) { return; } if (threadIndex != 0) { Thread.SetData(slot, threadIndex); } if (!barrierSignalAndWait()) { return; } Assert.Equal(threadIndex, Thread.GetData(slot)); if (!barrierSignalAndWait()) { return; } } catch (Exception ex) { cancellationTokenSource.Cancel(); throw new TargetInvocationException(ex); } }; for (int i = 0; i < threadArray.Length; ++i) { threadArray[i] = ThreadTestHelpers.CreateGuardedThread(out waitForThreadArray[i], () => threadMain(i)); threadArray[i].IsBackground = true; threadArray[i].Start(); } foreach (var waitForThread in waitForThreadArray) { waitForThread(); } }
public static object GetData(LocalDataStoreSlot slot) { return GetThreadLocal(slot).Value; }
public static void SetData(LocalDataStoreSlot slot, object value) { GetThreadLocal(slot).Value = value; }
private static ThreadLocal<object> GetThreadLocal(LocalDataStoreSlot slot) { if (slot == null) { throw new ArgumentNullException(nameof(slot)); } Debug.Assert(slot.Data != null); return slot.Data; }
public static void SetData(LocalDataStoreSlot slot, object data) => LocalDataStore.SetData(slot, data);
public static object GetData(LocalDataStoreSlot slot) => LocalDataStore.GetData(slot);
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; }
// Get the data in a particular data store slot. public static Object GetData(LocalDataStoreSlot slot) { if(slot == null) { return null; } else { return slot.Data; } }
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; }
static Slot() { rnd = new Random(); slt = Thread.AllocateDataSlot(); }
public static void SetData (LocalDataStoreSlot slot, object data) { Thread.CurrentContext.MyLocalStore.SetData (slot, data); }
// Free a data store slot with a specific name. internal static void FreeNamed(String name) { lock(typeof(LocalDataStoreSlot)) { LocalDataStoreSlot slot = namedSlots; LocalDataStoreSlot prev = null; while(slot != null) { if(slot.isNamed && slot.name == name) { if(prev != null) { prev.nextNamed = slot.nextNamed; } else { namedSlots = slot.nextNamed; } slot.free = true; return; } prev = slot; slot = slot.nextNamed; } } }