コード例 #1
0
        /*=========================================================================
        ** 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);
        }
コード例 #2
0
ファイル: _localdatastore.cs プロジェクト: ArildF/masters
        /*=========================================================================
        ** 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;
        }
コード例 #3
0
        /*=========================================================================
        ** 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);
                }
            }
        }
コード例 #4
0
        //=========================================================================
        // 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*/);
            }
        }
コード例 #5
0
ファイル: LocalDataStore.cs プロジェクト: randomize/VimConfig
        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);
        }
コード例 #6
0
ファイル: LocalDataStore.cs プロジェクト: randomize/VimConfig
        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);
                }
            }
        }
コード例 #7
0
ファイル: _localdatastore.cs プロジェクト: ArildF/masters
        /*=========================================================================
        ** 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*/ );
            }
        }
コード例 #8
0
        /*=========================================================================
        ** 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);
            }

        }