/*========================================================================= ** 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); }
/*========================================================================= ** 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; }
/*========================================================================= ** 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. bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(m_Manager, ref tookLock); if (!slot.IsValid()) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); } // Do the actual set operation. SetDataInternal(slot.Slot, data, true /*bAlloc*/); } finally { if (tookLock) { Monitor.Exit(m_Manager); } } }
//========================================================================= // 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*/); } }
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 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); } } }
/*========================================================================= ** 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(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); // Do the actual set operation. SetDataInternal(slot.Slot, data, true /*bAlloc*/ ); } }
/*========================================================================= ** 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. bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(m_Manager, ref tookLock); if (!slot.IsValid()) throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed")); // Do the actual set operation. SetDataInternal(slot.Slot, data, true /*bAlloc*/ ); } finally { if (tookLock) Monitor.Exit(m_Manager); } }