/*=========================================================================
        ** 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 ----s.
                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"));
        }
        private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot)
        {
            LocalDataStoreElement element;
            bool lockTaken = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                Monitor.Enter(this.m_Manager, ref lockTaken);
                int index = slot.Slot;
                if (index < 0)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
                }
                if (index >= this.m_DataTable.Length)
                {
                    LocalDataStoreElement[] destinationArray = new LocalDataStoreElement[this.m_Manager.GetSlotTableLength()];
                    Array.Copy(this.m_DataTable, destinationArray, this.m_DataTable.Length);
                    this.m_DataTable = destinationArray;
                }
                if (this.m_DataTable[index] == null)
                {
                    this.m_DataTable[index] = new LocalDataStoreElement(slot.Cookie);
                }
                element = this.m_DataTable[index];
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(this.m_Manager);
                }
            }
            return(element);
        }
Esempio n. 3
0
        private LocalDataStoreElement PopulateElement(LocalDataStoreSlot slot)
        {
            bool lockTaken = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                Monitor.Enter((object)this.m_Manager, ref lockTaken);
                int slot1 = slot.Slot;
                if (slot1 < 0)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SlotHasBeenFreed"));
                }
                if (slot1 >= this.m_DataTable.Length)
                {
                    LocalDataStoreElement[] dataStoreElementArray = new LocalDataStoreElement[this.m_Manager.GetSlotTableLength()];
                    Array.Copy((Array)this.m_DataTable, (Array)dataStoreElementArray, this.m_DataTable.Length);
                    this.m_DataTable = dataStoreElementArray;
                }
                if (this.m_DataTable[slot1] == null)
                {
                    this.m_DataTable[slot1] = new LocalDataStoreElement(slot.Cookie);
                }
                return(this.m_DataTable[slot1]);
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit((object)this.m_Manager);
                }
            }
        }
 internal void FreeData(int slot, long cookie)
 {
     if (slot < this.m_DataTable.Length)
     {
         LocalDataStoreElement element = this.m_DataTable[slot];
         if ((element != null) && (element.Cookie == cookie))
         {
             this.m_DataTable[slot] = null;
         }
     }
 }
        // Token: 0x06000FDB RID: 4059 RVA: 0x0003041C File Offset: 0x0002E61C
        internal void FreeData(int slot, long cookie)
        {
            if (slot >= this.m_DataTable.Length)
            {
                return;
            }
            LocalDataStoreElement localDataStoreElement = this.m_DataTable[slot];

            if (localDataStoreElement != null && localDataStoreElement.Cookie == cookie)
            {
                this.m_DataTable[slot] = null;
            }
        }
Esempio n. 6
0
        internal void FreeData(int slot, long cookie)
        {
            if (slot >= this.m_DataTable.Length)
            {
                return;
            }
            LocalDataStoreElement dataStoreElement = this.m_DataTable[slot];

            if (dataStoreElement == null || dataStoreElement.Cookie != cookie)
            {
                return;
            }
            this.m_DataTable[slot] = (LocalDataStoreElement)null;
        }
        [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);
                }
            }
        }
        /*=========================================================================
        ** This method does clears the unused slot.
        * Assumes lock on m_Manager is taken
        *  =========================================================================*/
        internal void FreeData(int slot, long cookie)
        {
            // We try to delay allocate the dataTable (in cases like the manager clearing a
            // just-freed slot in all stores
            if (slot >= m_DataTable.Length)
            {
                return;
            }

            LocalDataStoreElement element = m_DataTable[slot];

            if (element != null && element.Cookie == cookie)
            {
                m_DataTable[slot] = null;
            }
        }
Esempio n. 9
0
        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"));
        }
        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 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"));
        }
        /*=========================================================================
        ** 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);
        }
Esempio n. 14
0
        [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);
            }
        }
		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;
		}