public EventProvider(Guid providerGuid) { this.m_providerId = providerGuid; s_returnCodeSlot = Thread.AllocateDataSlot(); Thread.SetData(s_returnCodeSlot, 0); this.EtwRegister(); }
static DatabaseControl() { //log4net.Config.XmlConfigurator.Configure(); AutoMappingConfiguration cfg = new AutoMappingConfiguration(); System.Reflection.Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(w => w.FullName.Contains("ComprasColetivas.Domain.Model")).ToArray(); factory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(Properties.Settings.Default.ConnectionStringSQLServer).ShowSql()) .Mappings(m => { m.AutoMappings.Add(AutoMap.Assemblies(cfg, assemblies).Conventions.Setup(c => { c.Add<PrimaryKeyConvention>(); c.Add<CustomForeignKeyConvention>(); c.Add<DefaultStringLengthConvention>(); c.Add<TableConvention>(); c.Add<EnumMappingConvention>(); }) ); m.AutoMappings.ToList()[0].IncludeBase<Pessoa>(); m.AutoMappings.ToList()[0].IncludeBase<Pagamento>(); }).ExposeConfiguration(BuildSchema).BuildSessionFactory(); mysessions = Thread.AllocateDataSlot(); }
private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot) { bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); LocalDataStoreElement result; try { Monitor.Enter(this.m_Manager, ref flag); int slot2 = slot.Slot; if (slot2 < 0) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); } if (slot2 >= this.m_DataTable.Length) { int slotTableLength = this.m_Manager.GetSlotTableLength(); LocalDataStoreElement[] array = new LocalDataStoreElement[slotTableLength]; Array.Copy(this.m_DataTable, array, this.m_DataTable.Length); this.m_DataTable = array; } if (this.m_DataTable[slot2] == null) { this.m_DataTable[slot2] = new LocalDataStoreElement(slot.Cookie); } result = this.m_DataTable[slot2]; } finally { if (flag) { Monitor.Exit(this.m_Manager); } } return result; }
/// <summary> /// 根据Request对象初始化所需环境信息 /// </summary> /// <param name="request"></param> public static void InitHttpEnv(HttpRequest request) { HttpEnvInfo hei = new HttpEnvInfo(request); _HttpEnvSlot = Thread.AllocateDataSlot(); Thread.SetData(_HttpEnvSlot, hei as IHttpEnvInterface); }
static TxDataContextDriver() { AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; _threadStorageSlot = Thread.AllocateDataSlot(); CopySampleTraces(); }
/*========================================================================= ** Retrieves the value from the specified slot. =========================================================================*/ public Object GetData(LocalDataStoreSlot slot) { Object o = null; // Validate the slot. m_Manager.ValidateSlot(slot); // Cache the slot index to avoid synchronization issues. int slotIdx = slot.Slot; if (slotIdx >= 0) { // Delay expansion of m_DataTable if we can if (slotIdx >= m_DataTable.Length) return null; // Retrieve the data from the given slot. o = m_DataTable[slotIdx]; } // Check if the slot has become invalid. if (!slot.IsValid()) throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); return o; }
/// <summary> /// Static constructor creates a new session factory used by all instances /// of this class. /// </summary> static Repository() { Configuration cfg = new Configuration(); cfg.AddAssembly("SFASystem.Domain"); factory = cfg.BuildSessionFactory(); mysessions = Thread.AllocateDataSlot(); }
public LocalDataStoreSlot AllocateDataSlot() { LocalDataStoreSlot slot2; bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { long num4; Monitor.Enter(this, ref lockTaken); int length = this.m_SlotInfoTable.Length; if (this.m_FirstAvailableSlot >= length) { int num2; if (length < 0x200) { num2 = length * 2; } else { num2 = length + 0x80; } bool[] destinationArray = new bool[num2]; Array.Copy(this.m_SlotInfoTable, destinationArray, length); this.m_SlotInfoTable = destinationArray; this.m_FirstAvailableSlot = length; length = num2; } int firstAvailableSlot = this.m_FirstAvailableSlot; while (true) { if (!this.m_SlotInfoTable[firstAvailableSlot]) { break; } firstAvailableSlot++; } this.m_SlotInfoTable[firstAvailableSlot] = true; this.m_CookieGenerator = (num4 = this.m_CookieGenerator) + 1L; LocalDataStoreSlot slot = new LocalDataStoreSlot(this, firstAvailableSlot, num4); firstAvailableSlot++; while (firstAvailableSlot < length) { if (this.m_SlotInfoTable[firstAvailableSlot]) { break; } firstAvailableSlot++; } this.m_FirstAvailableSlot = firstAvailableSlot; slot2 = slot; } finally { if (lockTaken) { Monitor.Exit(this); } } return slot2; }
public void Close() { // Clear the hard refs; then, the only remaining refs to // all values we were storing are weak (unless somewhere // else is still using them) and so GC may reclaim them: hardRefs = null; t = null; }
public virtual void Close() { // Clear the hard refs; then, the only remaining refs to // all values we were storing are weak (unless somewhere // else is still using them) and so GC may reclaim them: hardRefs = null; t = null; }
//========================================================================= // Allocate a slot and associate a name with it. //========================================================================= public LocalDataStoreSlot AllocateNamedDataSlot(String name) { lock (this) { // Allocate a normal data slot. LocalDataStoreSlot slot = AllocateDataSlot(); // Insert the association between the name and the data slot number // in the hash table. m_KeyToSlotMap.Add(name, slot); return(slot); } }
public static void ThreadFunction(int i) { var counter = 0; LocalDataStorageSlot = Thread.AllocateNamedDataSlot(i.ToString()); Thread.SetData(LocalDataStorageSlot, counter); while (true) { SharedFunction(); Thread.Sleep(3000); } }
public LocalDataStoreSlot AllocateDataSlot() { LocalDataStoreSlot slot2; bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { LocalDataStoreSlot slot; int num3; Monitor.ReliableEnter(this, ref tookLock); int length = this.m_SlotInfoTable.Length; if (this.m_FirstAvailableSlot < length) { slot = new LocalDataStoreSlot(this, this.m_FirstAvailableSlot); this.m_SlotInfoTable[this.m_FirstAvailableSlot] = 1; int index = this.m_FirstAvailableSlot + 1; while (index < length) { if ((this.m_SlotInfoTable[index] & 1) == 0) { break; } index++; } this.m_FirstAvailableSlot = index; return slot; } if (length < 0x200) { num3 = length * 2; } else { num3 = length + 0x80; } byte[] destinationArray = new byte[num3]; Array.Copy(this.m_SlotInfoTable, destinationArray, length); this.m_SlotInfoTable = destinationArray; slot = new LocalDataStoreSlot(this, length); this.m_SlotInfoTable[length] = 1; this.m_FirstAvailableSlot = length + 1; slot2 = slot; } finally { if (tookLock) { Monitor.Exit(this); } } return slot2; }
[System.Security.SecuritySafeCritical] // auto-generated private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot) { bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(m_Manager, ref tookLock); // Make sure that the slot was not freed in the meantime int slotIdx = slot.Slot; if (slotIdx < 0) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); } if (slotIdx >= m_DataTable.Length) { int capacity = m_Manager.GetSlotTableLength(); // Validate that the specified capacity is larger than the current one. Contract.Assert(capacity >= m_DataTable.Length, "LocalDataStore corrupted: capacity >= m_DataTable.Length"); // Allocate the new data table. LocalDataStoreElement[] NewDataTable = new LocalDataStoreElement[capacity]; // Copy all the objects into the new table. Array.Copy(m_DataTable, NewDataTable, m_DataTable.Length); // Save the new table. m_DataTable = NewDataTable; } // Validate that there is enough space in the local data store now Contract.Assert(slotIdx < m_DataTable.Length, "LocalDataStore corrupted: slotIdx < m_DataTable.Length"); if (m_DataTable[slotIdx] == null) { m_DataTable[slotIdx] = new LocalDataStoreElement(slot.Cookie); } return(m_DataTable[slotIdx]); } finally { if (tookLock) { Monitor.Exit(m_Manager); } } }
static ThreadTrace() { logFileName = Environment.GetEnvironmentVariable("ThreadTrace"); if (logFileName == null) logFileName = ""; isEnabled = logFileName.Length > 0; if (isEnabled) { slot = Thread.AllocateDataSlot(); logs = new List<ThreadLog>(); NativeMethods.QueryPerformanceFrequency(out frequency); Console.WriteLine("ThreadTrace: enabled"); new Thread(ThreadProc).Start(); } }
public LocalDataStoreSlot AllocateDataSlot() { bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); LocalDataStoreSlot result; try { Monitor.Enter(this, ref flag); int num = this.m_SlotInfoTable.Length; int num2 = this.m_FirstAvailableSlot; while (num2 < num && this.m_SlotInfoTable[num2]) { num2++; } if (num2 >= num) { int num3; if (num < 512) { num3 = num * 2; } else { num3 = num + 128; } bool[] array = new bool[num3]; Array.Copy(this.m_SlotInfoTable, array, num); this.m_SlotInfoTable = array; } this.m_SlotInfoTable[num2] = true; int slot = num2; long cookieGenerator = this.m_CookieGenerator; this.m_CookieGenerator = checked (cookieGenerator + 1L); LocalDataStoreSlot localDataStoreSlot = new LocalDataStoreSlot(this, slot, cookieGenerator); this.m_FirstAvailableSlot = num2 + 1; result = localDataStoreSlot; } finally { if (flag) { Monitor.Exit(this); } } return(result); }
//========================================================================= // Retrieve the slot associated with a name, allocating it if no such // association has been defined. //========================================================================= public LocalDataStoreSlot GetNamedDataSlot(String name) { lock (this) { // Lookup in the hashtable to try find a slot for the name. LocalDataStoreSlot slot = (LocalDataStoreSlot)m_KeyToSlotMap[name]; // If the name is not yet in the hashtable then add it. if (null == slot) { return(AllocateNamedDataSlot(name)); } // The name was in the hashtable so return the associated slot. return(slot); } }
public void SetData(LocalDataStoreSlot slot, object data) { this.m_Manager.ValidateSlot(slot); int slot1 = slot.Slot; if (slot1 >= 0) { LocalDataStoreElement dataStoreElement = (slot1 < this.m_DataTable.Length ? this.m_DataTable[slot1] : (LocalDataStoreElement)null) ?? this.PopulateElement(slot); if (dataStoreElement.Cookie == slot.Cookie) { dataStoreElement.Value = data; return; } } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
//========================================================================= // Sets the data in the specified slot. //========================================================================= public void SetData(LocalDataStoreSlot slot, Object data) { // Validate the slot. m_Manager.ValidateSlot(slot); // I can't think of a way to avoid the race described in the // LocalDataStoreSlot finalizer method without a lock. lock (m_Manager) { if (!slot.IsValid()) { throw new InvalidOperationException("InvalidOperation_SlotHasBeenFreed"); } // Do the actual set operation. SetDataInternal(slot.Slot, data, true /*bAlloc*/); } }
static Tracer() { TraceKind[] verbosityLevels = new TraceKind[10]; verbosityLevels[1] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message; verbosityLevels[2] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message; verbosityLevels[3] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info; verbosityLevels[4] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info; verbosityLevels[5] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info; verbosityLevels[6] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info | TraceKind.Note; verbosityLevels[7] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info | TraceKind.Note; verbosityLevels[8] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info | TraceKind.Note; verbosityLevels[9] = TraceKind.All; VerbosityLevels = verbosityLevels; _indentLevelStore = Thread.AllocateDataSlot(); _traceMask = (TraceKind)VerbosityLevels[1]; _tracers = new Dictionary<string, Tracer>(); }
public void SetData(LocalDataStoreSlot slot, object data) { this.m_Manager.ValidateSlot(slot); int slot2 = slot.Slot; if (slot2 >= 0) { LocalDataStoreElement localDataStoreElement = (slot2 < this.m_DataTable.Length) ? this.m_DataTable[slot2] : null; if (localDataStoreElement == null) { localDataStoreElement = this.PopulateElement(slot); } if (localDataStoreElement.Cookie == slot.Cookie) { localDataStoreElement.Value = data; return; } } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
public static void SetGlobalContextData <T>(string name, T value) { if (HttpContext.Current != null) { HttpContext.Current.Items[name] = value; } else { System.LocalDataStoreSlot namedDataSlot = System.Threading.Thread.GetNamedDataSlot(name); if (namedDataSlot == null) { namedDataSlot = System.Threading.Thread.AllocateNamedDataSlot(name); } if (namedDataSlot != null) { System.Threading.Thread.SetData(namedDataSlot, value); } } }
static Tracer() { TraceKind[] verbosityLevels = new TraceKind[10]; verbosityLevels[1] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message; verbosityLevels[2] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message; verbosityLevels[3] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info; verbosityLevels[4] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info; verbosityLevels[5] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info; verbosityLevels[6] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info | TraceKind.Note; verbosityLevels[7] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info | TraceKind.Note; verbosityLevels[8] = TraceKind.Exception | TraceKind.Assert | TraceKind.Error | TraceKind.Warning | TraceKind.Message | TraceKind.Info | TraceKind.Note; verbosityLevels[9] = TraceKind.All; VerbosityLevels = verbosityLevels; _indentLevelStore = Thread.AllocateDataSlot(); _traceMask = (TraceKind)VerbosityLevels[1]; _tracers = new Dictionary<string, Tracer>(); _tracersListSync = new RWObjectLocker(); GlobalData.Current.DanglingStaticDisposables.Add(typeof(Tracer)); }
public void SetData(LocalDataStoreSlot slot, object data) { this.m_Manager.ValidateSlot(slot); int index = slot.Slot; if (index >= 0) { LocalDataStoreElement element = (index < this.m_DataTable.Length) ? this.m_DataTable[index] : null; if (element == null) { element = this.PopulateElement(slot); } if (element.Cookie == slot.Cookie) { element.Value = data; return; } } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
public LocalDataStoreSlot AllocateNamedDataSlot(string name) { bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter((object)this, ref lockTaken); LocalDataStoreSlot localDataStoreSlot = this.AllocateDataSlot(); this.m_KeyToSlotMap.Add(name, localDataStoreSlot); return(localDataStoreSlot); } finally { if (lockTaken) { Monitor.Exit((object)this); } } }
public object GetData(LocalDataStoreSlot slot) { object obj2 = null; this.m_Manager.ValidateSlot(slot); int index = slot.Slot; if (index >= 0) { if (index >= this.m_DataTable.Length) { return(null); } obj2 = this.m_DataTable[index]; } if (!slot.IsValid()) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); } return(obj2); }
public static T GetGlobalContextData <T>(string name) { if (((HttpContext.Current != null) && (HttpContext.Current.Items[name] != null) && (HttpContext.Current.Items[name].GetType() == typeof(T)))) { return((T)HttpContext.Current.Items[name]); } if (System.Threading.Thread.GetNamedDataSlot(name) != null) { object data = null; System.LocalDataStoreSlot namedDataSlot = System.Threading.Thread.GetNamedDataSlot(name); if (namedDataSlot != null) { data = System.Threading.Thread.GetData(namedDataSlot); } if ((data != null) && (data.GetType() == typeof(T))) { return((T)data); } } return(default(T)); }
public void TestDatastore () { otherCtx = cbo.GetContext (); slot = Context.AllocateDataSlot (); LocalDataStoreSlot namedSlot1 = Context.AllocateNamedDataSlot ("slot1"); LocalDataStoreSlot namedSlot2 = Context.GetNamedDataSlot ("slot2"); Context.SetData (slot, "data"); Context.SetData (namedSlot1, "data1"); Context.SetData (namedSlot2, "data2"); otherCtx.DoCallBack (new CrossContextDelegate (CheckOtherContextDatastore)); Assert.IsTrue (Context.GetData (slot).Equals ("data"), "Wrong data 1"); Assert.IsTrue (Context.GetData (namedSlot1).Equals ("data1"), "Wrong data 2"); Assert.IsTrue (Context.GetData (namedSlot2).Equals ("data2"), "Wrong data 3"); try { namedSlot1 = Context.AllocateNamedDataSlot ("slot1"); Assert.Fail ("Exception expected"); } catch {} Context.FreeNamedDataSlot ("slot1"); Context.FreeNamedDataSlot ("slot2"); try { namedSlot1 = Context.AllocateNamedDataSlot ("slot1"); } catch { Assert.Fail ("Exception not expected"); } Context.FreeNamedDataSlot ("slot1"); }
public LocalDataStoreSlot AllocateNamedDataSlot(string name) { LocalDataStoreSlot slot2; bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this, ref tookLock); LocalDataStoreSlot slot = this.AllocateDataSlot(); this.m_KeyToSlotMap.Add(name, slot); slot2 = slot; } finally { if (tookLock) { Monitor.Exit(this); } } return(slot2); }
/*========================================================================= ** Allocate a slot and associate a name with it. ** =========================================================================*/ public LocalDataStoreSlot AllocateNamedDataSlot(String name) { bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this, ref tookLock); // Allocate a normal data slot. LocalDataStoreSlot slot = AllocateDataSlot(); // Insert the association between the name and the data slot number // in the hash table. m_KeyToSlotMap.Add(name, slot); return(slot); } finally { if (tookLock) { Monitor.Exit(this); } } }
public object GetData(LocalDataStoreSlot slot) { this.m_Manager.ValidateSlot(slot); int slot2 = slot.Slot; if (slot2 >= 0) { if (slot2 >= this.m_DataTable.Length) { return null; } LocalDataStoreElement localDataStoreElement = this.m_DataTable[slot2]; if (localDataStoreElement == null) { return null; } if (localDataStoreElement.Cookie == slot.Cookie) { return localDataStoreElement.Value; } } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
public void SetData(LocalDataStoreSlot slot, object data) { this.m_Manager.ValidateSlot(slot); bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this.m_Manager, ref tookLock); if (!slot.IsValid()) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); } this.SetDataInternal(slot.Slot, data, true); } finally { if (tookLock) { Monitor.Exit(this.m_Manager); } } }
public object GetData(LocalDataStoreSlot slot) { this.m_Manager.ValidateSlot(slot); int index = slot.Slot; if (index >= 0) { if (index >= this.m_DataTable.Length) { return(null); } LocalDataStoreElement element = this.m_DataTable[index]; if (element == null) { return(null); } if (element.Cookie == slot.Cookie) { return(element.Value); } } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
public LocalDataStoreSlot AllocateNamedDataSlot(string name) { bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); LocalDataStoreSlot result; try { Monitor.Enter(this, ref flag); LocalDataStoreSlot localDataStoreSlot = this.AllocateDataSlot(); this.m_KeyToSlotMap.Add(name, localDataStoreSlot); result = localDataStoreSlot; } finally { if (flag) { Monitor.Exit(this); } } return(result); }
public LocalDataStoreSlot AllocateDataSlot() { bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter((object)this, ref lockTaken); int length = this.m_SlotInfoTable.Length; int index = this.m_FirstAvailableSlot; while (index < length && this.m_SlotInfoTable[index]) { ++index; } if (index >= length) { bool[] flagArray = new bool[length >= 512 ? length + 128 : length * 2]; Array.Copy((Array)this.m_SlotInfoTable, (Array)flagArray, length); this.m_SlotInfoTable = flagArray; } this.m_SlotInfoTable[index] = true; int slot = index; long num = this.m_CookieGenerator; this.m_CookieGenerator = checked (num + 1L); long cookie = num; LocalDataStoreSlot localDataStoreSlot = new LocalDataStoreSlot(this, slot, cookie); this.m_FirstAvailableSlot = index + 1; return(localDataStoreSlot); } finally { if (lockTaken) { Monitor.Exit((object)this); } } }
/*========================================================================= ** Retrieves the value from the specified slot. ** =========================================================================*/ public Object GetData(LocalDataStoreSlot slot) { // Validate the slot. m_Manager.ValidateSlot(slot); // Cache the slot index to avoid synchronization issues. int slotIdx = slot.Slot; if (slotIdx >= 0) { // Delay expansion of m_DataTable if we can if (slotIdx >= m_DataTable.Length) { return(null); } // Retrieve the data from the given slot. LocalDataStoreElement element = m_DataTable[slotIdx]; //Initially we prepopulate the elements to be null. if (element == null) { return(null); } // Check that the element is owned by this slot by comparing cookies. // This is necesary to avoid resurection ----s. if (element.Cookie == slot.Cookie) { return(element.Value); } // Fall thru and throw exception } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot) { bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); LocalDataStoreElement result; try { Monitor.Enter(this.m_Manager, ref flag); int slot2 = slot.Slot; if (slot2 < 0) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); } if (slot2 >= this.m_DataTable.Length) { int slotTableLength = this.m_Manager.GetSlotTableLength(); LocalDataStoreElement[] array = new LocalDataStoreElement[slotTableLength]; Array.Copy(this.m_DataTable, array, this.m_DataTable.Length); this.m_DataTable = array; } if (this.m_DataTable[slot2] == null) { this.m_DataTable[slot2] = new LocalDataStoreElement(slot.Cookie); } result = this.m_DataTable[slot2]; } finally { if (flag) { Monitor.Exit(this.m_Manager); } } return(result); }
/*========================================================================= ** Allocates a data slot by finding an available index and wrapping it ** an object to prevent clients from manipulating it directly, allowing us ** to make assumptions its integrity. ** =========================================================================*/ public LocalDataStoreSlot AllocateDataSlot() { lock (this) { int i; LocalDataStoreSlot slot; // Retrieve the current size of the table. int SlotTableSize = m_SlotInfoTable.Length; // Check if there are any slots left. if (m_FirstAvailableSlot < SlotTableSize) { // Save the first available slot. slot = new LocalDataStoreSlot(this, m_FirstAvailableSlot); m_SlotInfoTable[m_FirstAvailableSlot] = DataSlotOccupied; // Find the next available slot. for (i = m_FirstAvailableSlot + 1; i < SlotTableSize; ++i) { if (0 == (m_SlotInfoTable[i] & DataSlotOccupied)) { break; } } // Save the new "first available slot". m_FirstAvailableSlot = i; // Return the slot index. return(slot); } // The table is full so we need to increase its size. int NewSlotTableSize; if (SlotTableSize < SlotTableDoubleThreshold) { // The table is still relatively small so double it. NewSlotTableSize = SlotTableSize * 2; } else { // The table is relatively large so simply increase its size by a given amount. NewSlotTableSize = SlotTableSize + LargeSlotTableSizeIncrease; } // Allocate the new slot info table. byte[] NewSlotInfoTable = new byte[NewSlotTableSize]; // Copy the old array into the new one. Array.Copy(m_SlotInfoTable, NewSlotInfoTable, SlotTableSize); m_SlotInfoTable = NewSlotInfoTable; // SlotTableSize is the index of the first empty slot in the expanded table. slot = new LocalDataStoreSlot(this, SlotTableSize); m_SlotInfoTable[SlotTableSize] = DataSlotOccupied; m_FirstAvailableSlot = SlotTableSize + 1; // Return the selected slot return(slot); } }
[System.Security.SecurityCritical] // auto-generated_required public static Object GetData(LocalDataStoreSlot slot) { return Thread.CurrentContext.MyLocalStore.GetData(slot); }
public LocalDataStoreSlot AllocateDataSlot() { LocalDataStoreSlot slot2; bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { long num4; Monitor.Enter(this, ref lockTaken); int length = this.m_SlotInfoTable.Length; if (this.m_FirstAvailableSlot >= length) { int num2; if (length < 0x200) { num2 = length * 2; } else { num2 = length + 0x80; } bool[] destinationArray = new bool[num2]; Array.Copy(this.m_SlotInfoTable, destinationArray, length); this.m_SlotInfoTable = destinationArray; this.m_FirstAvailableSlot = length; length = num2; } int firstAvailableSlot = this.m_FirstAvailableSlot; while (true) { if (!this.m_SlotInfoTable[firstAvailableSlot]) { break; } firstAvailableSlot++; } this.m_SlotInfoTable[firstAvailableSlot] = true; this.m_CookieGenerator = (num4 = this.m_CookieGenerator) + 1L; LocalDataStoreSlot slot = new LocalDataStoreSlot(this, firstAvailableSlot, num4); firstAvailableSlot++; while (firstAvailableSlot < length) { if (this.m_SlotInfoTable[firstAvailableSlot]) { break; } firstAvailableSlot++; } this.m_FirstAvailableSlot = firstAvailableSlot; slot2 = slot; } finally { if (lockTaken) { Monitor.Exit(this); } } return(slot2); }
public void OnDeserialization(object sender) { slot = Thread.AllocateNamedDataSlot("CastlePerThread"); instances = new List<Burden>(); }
[System.Security.SecurityCritical] // auto-generated_required public static void SetData(LocalDataStoreSlot slot, Object data) { Thread.CurrentContext.MyLocalStore.SetData(slot, data); }
public void ValidateSlot(LocalDataStoreSlot slot) { if (slot == null || slot.Manager != this) { throw new ArgumentException(Environment.GetResourceString("Argument_ALSInvalidSlot")); } }
public static object GetData(LocalDataStoreSlot slot) { LocalDataStoreManager.ValidateSlot(slot); LocalDataStore domainLocalStore = GetDomainLocalStore(); if (domainLocalStore == null) { return null; } return domainLocalStore.GetData(slot); }
private static void SaveContextToStore(LocalDataStoreSlot storeSlot, CSContext context) { Thread.SetData(storeSlot, context); }
} // 0x0000000180631650-0x00000001806316C0 private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot) => default; // 0x00000001806317B0-0x0000000180631A80
[System.Security.SecuritySafeCritical] // auto-generated private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot) { bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(m_Manager, ref tookLock); // Make sure that the slot was not freed in the meantime int slotIdx = slot.Slot; if (slotIdx < 0) throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); if (slotIdx >= m_DataTable.Length) { int capacity = m_Manager.GetSlotTableLength(); // Validate that the specified capacity is larger than the current one. Contract.Assert(capacity >= m_DataTable.Length, "LocalDataStore corrupted: capacity >= m_DataTable.Length"); // Allocate the new data table. LocalDataStoreElement[] NewDataTable = new LocalDataStoreElement[capacity]; // Copy all the objects into the new table. Array.Copy(m_DataTable, NewDataTable, m_DataTable.Length); // Save the new table. m_DataTable = NewDataTable; } // Validate that there is enough space in the local data store now Contract.Assert(slotIdx < m_DataTable.Length, "LocalDataStore corrupted: slotIdx < m_DataTable.Length"); if (m_DataTable[slotIdx] == null) m_DataTable[slotIdx] = new LocalDataStoreElement(slot.Cookie); return m_DataTable[slotIdx]; } finally { if (tookLock) Monitor.Exit(m_Manager); } }
[System.Security.SecuritySafeCritical] // auto-generated public LocalDataStoreSlot AllocateDataSlot() { bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(this, ref tookLock); LocalDataStoreSlot slot; int slotTableSize = m_SlotInfoTable.Length; // In case FreeDataSlot has moved the pointer back, the next slot may not be available. // Find the first actually available slot. int availableSlot = m_FirstAvailableSlot; while (availableSlot < slotTableSize) { if (!m_SlotInfoTable[availableSlot]) { break; } availableSlot++; } // Check if there are any slots left. if (availableSlot >= slotTableSize) { // The table is full so we need to increase its size. int newSlotTableSize; if (slotTableSize < SlotTableDoubleThreshold) { // The table is still relatively small so double it. newSlotTableSize = slotTableSize * 2; } else { // The table is relatively large so simply increase its size by a given amount. newSlotTableSize = slotTableSize + LargeSlotTableSizeIncrease; } // Allocate the new slot info table. bool[] newSlotInfoTable = new bool[newSlotTableSize]; // Copy the old array into the new one. Array.Copy(m_SlotInfoTable, newSlotInfoTable, slotTableSize); m_SlotInfoTable = newSlotInfoTable; } // availableSlot is the index of the empty slot. m_SlotInfoTable[availableSlot] = true; // We do not need to worry about overflowing m_CookieGenerator. It would take centuries // of intensive slot allocations on current machines to get the 2^64 counter to overflow. // We will perform the increment with overflow check just to play it on the safe side. slot = new LocalDataStoreSlot(this, availableSlot, checked (m_CookieGenerator++)); // Save the new "first available slot".hint m_FirstAvailableSlot = availableSlot + 1; // Return the selected slot return(slot); } finally { if (tookLock) { Monitor.Exit(this); } } }
/*========================================================================= ** Sets the data in the specified slot. =========================================================================*/ public void SetData(LocalDataStoreSlot slot, Object data) { // Validate the slot. m_Manager.ValidateSlot(slot); // Cache the slot index to avoid synchronization issues. int slotIdx = slot.Slot; if (slotIdx >= 0) { LocalDataStoreElement element = (slotIdx < m_DataTable.Length) ? m_DataTable[slotIdx] : null; if (element == null) { element = PopulateElement(slot); } // Check that the element is owned by this slot by comparing cookies. // This is necesary to avoid resurection race conditions. if (element.Cookie == slot.Cookie) { // Set the data on the given slot. element.Value = data; return; } // Fall thru and throw exception } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
/*========================================================================= ** Retrieves the value from the specified slot. =========================================================================*/ public Object GetData(LocalDataStoreSlot slot) { // Validate the slot. m_Manager.ValidateSlot(slot); // Cache the slot index to avoid synchronization issues. int slotIdx = slot.Slot; if (slotIdx >= 0) { // Delay expansion of m_DataTable if we can if (slotIdx >= m_DataTable.Length) return null; // Retrieve the data from the given slot. LocalDataStoreElement element = m_DataTable[slotIdx]; //Initially we prepopulate the elements to be null. if (element == null) return null; // Check that the element is owned by this slot by comparing cookies. // This is necesary to avoid resurection race conditions. if (element.Cookie == slot.Cookie) return element.Value; // Fall thru and throw exception } throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); }
public static void SetData(LocalDataStoreSlot slot, object data) { LocalDataStore domainLocalStore = GetDomainLocalStore(); if (domainLocalStore == null) { domainLocalStore = LocalDataStoreManager.CreateLocalDataStore(); SetDomainLocalStore(domainLocalStore); } domainLocalStore.SetData(slot, data); }
/// <summary> /// Creates a new Prexonite virtual machine. /// </summary> public Engine() { //Thread local storage for stack _stackSlot = Thread.AllocateDataSlot(); //Metatable _meta = MetaTable.Create(); //PTypes _pTypeMap = new Dictionary<Type, PType>(); _ptypemapiterator = new PTypeMapIterator(this); //int PTypeMap[typeof (int)] = PType.Int; PTypeMap[typeof (long)] = PType.Int; PTypeMap[typeof (short)] = PType.Int; PTypeMap[typeof (byte)] = PType.Int; #if UseNonCTSIntegers PTypeMap[typeof(uint)] = IntPType.Instance; PTypeMap[typeof(ulong)] = IntPType.Instance; PTypeMap[typeof(ushort)] = IntPType.Instance; PTypeMap[typeof(sbyte)] = IntPType.Instance; #endif //char PTypeMap[typeof (char)] = PType.Char; //bool PTypeMap[typeof (bool)] = PType.Bool; //real PTypeMap[typeof (float)] = PType.Real; PTypeMap[typeof (double)] = PType.Real; //string PTypeMap[typeof (string)] = PType.String; PTypeMap[typeof (List<PValue>)] = PType.List; PTypeMap[typeof (PValue[])] = PType.List; PTypeMap[typeof (PValueHashtable)] = PType.Hash; //Registry _pTypeRegistry = new SymbolTable<Type>(); _pTypeRegistryIterator = new PTypeRegistryIterator(this); PTypeRegistry[IntPType.Literal] = typeof (IntPType); PTypeRegistry[BoolPType.Literal] = typeof (BoolPType); PTypeRegistry[RealPType.Literal] = typeof (RealPType); PTypeRegistry[CharPType.Literal] = typeof (CharPType); PTypeRegistry[StringPType.Literal] = typeof (StringPType); PTypeRegistry[NullPType.Literal] = typeof (NullPType); PTypeRegistry[ObjectPType.Literal] = typeof (ObjectPType); PTypeRegistry[ListPType.Literal] = typeof (ListPType); PTypeRegistry[StructurePType.Literal] = typeof (StructurePType); PTypeRegistry[HashPType.Literal] = typeof (HashPType); PTypeRegistry[StructurePType.Literal] = typeof (StructurePType); //Assembly registry _registeredAssemblies = new List<Assembly>(); foreach ( var assName in Assembly.GetExecutingAssembly().GetReferencedAssemblies()) _registeredAssemblies.Add(Assembly.Load(assName.FullName)); //Commands _commandTable = new CommandTable(); PCommand cmd; Commands.AddEngineCommand(PrintAlias, ConsolePrint.Instance); Commands.AddEngineCommand(PrintLineAlias, ConsolePrintLine.Instance); Commands.AddEngineCommand(MetaAlias, Prexonite.Commands.Core.Meta.Instance); Commands.AddEngineCommand(BoxedAlias, Boxed.Instance); // The concatenate command has been renamed to `string_concat` for Prexonite 2 Commands.AddEngineCommand(ConcatenateAlias, Concat.Instance); Commands.AddEngineCommand(OldConcatenateAlias, Concat.Instance); Commands.AddEngineCommand(MapAlias, cmd = Map.Instance); Commands.AddEngineCommand(SelectAlias, cmd); Commands.AddEngineCommand(FoldLAlias, FoldL.Instance); Commands.AddEngineCommand(FoldRAlias, FoldR.Instance); Commands.AddEngineCommand(DisposeAlias, Dispose.Instance); // There is a macro that uses the same alias (CallAlias) // it has the same purpose. For backwards compatibility, // the command table will retain the old binding. Commands.AddEngineCommand(CallAlias, Call.Instance); Commands.AddEngineCommand(Call.Alias, Call.Instance); Commands.AddEngineCommand(ThunkAlias, ThunkCommand.Instance); Commands.AddEngineCommand(AsThunkAlias, AsThunkCommand.Instance); Commands.AddEngineCommand(ForceAlias, ForceCommand.Instance); Commands.AddEngineCommand(ToSeqAlias, ToSeqCommand.Instance); // There is a macro that uses the same alias (Call_MemberAlias) // it has the same purpose. For backwards compatibility, // the command table will retain the old binding. Commands.AddEngineCommand(Call_MemberAlias, Call_Member.Instance); Commands.AddEngineCommand(Call_Member.Alias, Call_Member.Instance); Commands.AddEngineCommand(CallerAlias, Caller.Instance); Commands.AddEngineCommand(PairAlias, Pair.Instance); Commands.AddEngineCommand(UnbindAlias, Unbind.Instance); Commands.AddEngineCommand(SortAlias, Sort.Instance); Commands.AddEngineCommand(SortAlternativeAlias, Sort.Instance); Commands.AddEngineCommand(LoadAssemblyAlias, LoadAssembly.Instance); Commands.AddEngineCommand(DebugAlias, new Debug()); Commands.AddEngineCommand(SetCenterAlias, SetCenterCommand.Instance); Commands.AddEngineCommand(SetLeftAlias, SetLeftCommand.Instance); Commands.AddEngineCommand(SetRightAlias, SetRightCommand.Instance); Commands.AddEngineCommand(AllAlias, All.Instance); Commands.AddEngineCommand(WhereAlias, Where.Instance); Commands.AddEngineCommand(SkipAlias, Skip.Instance); Commands.AddEngineCommand(LimitAlias, cmd = Limit.Instance); Commands.AddEngineCommand(TakeAlias, cmd); Commands.AddEngineCommand(AbsAlias, Abs.Instance); Commands.AddEngineCommand(CeilingAlias, Ceiling.Instance); Commands.AddEngineCommand(ExpAlias, Exp.Instance); Commands.AddEngineCommand(FloorAlias, Floor.Instance); Commands.AddEngineCommand(LogAlias, Log.Instance); Commands.AddEngineCommand(MaxAlias, Max.Instance); Commands.AddEngineCommand(MinAlias, Min.Instance); Commands.AddEngineCommand(PiAlias, Pi.Instance); Commands.AddEngineCommand(RoundAlias, Round.Instance); Commands.AddEngineCommand(SinAlias, Sin.Instance); Commands.AddEngineCommand(CosAlias, Cos.Instance); Commands.AddEngineCommand(SqrtAlias, Sqrt.Instance); Commands.AddEngineCommand(TanAlias, Tan.Instance); Commands.AddEngineCommand(CharAlias, Char.Instance); Commands.AddEngineCommand(CountAlias, Count.Instance); Commands.AddEngineCommand(DistinctAlias, cmd = new Distinct()); Commands.AddEngineCommand(UnionAlias, cmd); Commands.AddEngineCommand(UniqueAlias, cmd); Commands.AddEngineCommand(FrequencyAlias, new Frequency()); Commands.AddEngineCommand(GroupByAlias, new GroupBy()); Commands.AddEngineCommand(IntersectAlias, new Intersect()); // There is a macro that uses the same alias (Call_TailAlias) // it has the same purpose. For backwards compatibility, // the command table will retain the old binding. Commands.AddEngineCommand(Call_TailAlias, Call_Tail.Instance); Commands.AddEngineCommand(Call_Tail.Alias, Call_Tail.Instance); Commands.AddEngineCommand(ListAlias, List.Instance); Commands.AddEngineCommand(EachAlias, Each.Instance); Commands.AddEngineCommand(ExistsAlias, new Exists()); Commands.AddEngineCommand(ForAllAlias, new ForAll()); Commands.AddEngineCommand(CompileToCilAlias, CompileToCil.Instance); Commands.AddEngineCommand(TakeWhileAlias, TakeWhile.Instance); Commands.AddEngineCommand(ExceptAlias, Except.Instance); Commands.AddEngineCommand(RangeAlias, Range.Instance); Commands.AddEngineCommand(ReverseAlias, Reverse.Instance); Commands.AddEngineCommand(HeadTailAlias, HeadTail.Instance); Commands.AddEngineCommand(AppendAlias, Append.Instance); Commands.AddEngineCommand(SumAlias, Sum.Instance); Commands.AddEngineCommand(Contains.Alias, Contains.Instance); Commands.AddEngineCommand(ChanAlias, Chan.Instance); Commands.AddEngineCommand(SelectAlias, Select.Instance); Commands.AddEngineCommand(Call_AsyncAlias, CallAsync.Instance); Commands.AddEngineCommand(CallAsync.Alias, CallAsync.Instance); Commands.AddEngineCommand(AsyncSeqAlias, AsyncSeq.Instance); Commands.AddEngineCommand(CallSubPerformAlias, CallSubPerform.Instance); Commands.AddEngineCommand(PartialCallAlias, new PartialCallCommand()); Commands.AddEngineCommand(PartialMemberCallAlias, PartialMemberCallCommand.Instance); Commands.AddEngineCommand(PartialConstructionAlias, PartialConstructionCommand.Instance); Commands.AddEngineCommand(PartialTypeCheckAlias, PartialTypeCheckCommand.Instance); Commands.AddEngineCommand(PartialTypeCastAlias, PartialTypecastCommand.Instance); Commands.AddEngineCommand(PartialStaticCallAlias, PartialStaticCallCommand.Instance); Commands.AddEngineCommand(FunctionalPartialCallCommand.Alias, FunctionalPartialCallCommand.Instance); Commands.AddEngineCommand(FlippedFunctionalPartialCallCommand.Alias, FlippedFunctionalPartialCallCommand.Instance); Commands.AddEngineCommand(PartialCallStarImplCommand.Alias, PartialCallStarImplCommand.Instance); Commands.AddEngineCommand(ThenAlias, ThenCommand.Instance); Commands.AddEngineCommand(Id.Alias, Id.Instance); Commands.AddEngineCommand(Const.Alias, Const.Instance); OperatorCommands.AddToEngine(this); Commands.AddEngineCommand(CreateEnumerator.Alias, CreateEnumerator.Instance); Commands.AddEngineCommand(CreateModuleName.Alias, CreateModuleName.Instance); Commands.AddEngineCommand(GetUnscopedAstFactory.Alias, GetUnscopedAstFactory.Instance); Commands.AddEngineCommand(CreateSourcePosition.Alias, CreateSourcePosition.Instance); Commands.AddEngineCommand(SeqConcat.Alias, SeqConcat.Instance); }
public object GetData(LocalDataStoreSlot slot) => default; // 0x00000001806316C0-0x00000001806317B0 public void SetData(LocalDataStoreSlot slot, object data) { } // 0x0000000180631A80-0x0000000180631B90
internal ProjectService () { extensionChainSlot = Thread.AllocateDataSlot (); AddinManager.AddExtensionNodeHandler (FileFormatsExtensionPath, OnFormatExtensionChanged); AddinManager.AddExtensionNodeHandler (SerializableClassesExtensionPath, OnSerializableExtensionChanged); AddinManager.AddExtensionNodeHandler (ExtendedPropertiesExtensionPath, OnPropertiesExtensionChanged); AddinManager.AddExtensionNodeHandler (ProjectBindingsExtensionPath, OnProjectsExtensionChanged); AddinManager.ExtensionChanged += OnExtensionChanged; defaultFormat = formatManager.GetFileFormat ("MSBuild05"); }
} // 0x0000000180631620-0x0000000180631650 public object GetData(LocalDataStoreSlot slot) => default; // 0x00000001806316C0-0x00000001806317B0
public LocalDataStoreSlot AllocateDataSlot() { bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); LocalDataStoreSlot result; try { Monitor.Enter(this, ref flag); int num = this.m_SlotInfoTable.Length; if (this.m_FirstAvailableSlot >= num) { int num2; if (num < 512) { num2 = num * 2; } else { num2 = num + 128; } bool[] array = new bool[num2]; Array.Copy(this.m_SlotInfoTable, array, num); this.m_SlotInfoTable = array; this.m_FirstAvailableSlot = num; num = num2; } int num3 = this.m_FirstAvailableSlot; while (this.m_SlotInfoTable[num3]) { num3++; } this.m_SlotInfoTable[num3] = true; int arg_9A_1 = num3; long cookieGenerator; this.m_CookieGenerator = checked((cookieGenerator = this.m_CookieGenerator) + 1L); LocalDataStoreSlot localDataStoreSlot = new LocalDataStoreSlot(this, arg_9A_1, cookieGenerator); num3++; while (num3 < num && !this.m_SlotInfoTable[num3]) { num3++; } this.m_FirstAvailableSlot = num3; result = localDataStoreSlot; } finally { if (flag) { Monitor.Exit(this); } } return result; }
} // 0x0000000180631090-0x00000001806312B0 public void ValidateSlot(LocalDataStoreSlot slot) { } // 0x00000001806314E0-0x0000000180631560