示例#1
0
        public MmfObjectPtr Insert(MmfObjectPtr info, byte[] item)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }
            if (info == null)
            {
                throw new ArgumentNullException("item");
            }

            if (!info.View.IsOpen)
            {
                _viewManager.OpenView(info.View);
            }

            // Check if this item can be accomodated in existing space.
            if (info.Arena.HasDataSpace((uint)item.Length))
            {
                info.Arena.SetMemContents(item);
            }
            else
            {
                // Try to add it elsewhere and then delete the current space.
                MmfObjectPtr newInfo = Add(item);
                //if (newInfo != null)
                //{
                //Remove(info);  //as we are updating original hash table links, so before call remove we must update the hash-table entry, instead of updating later.
                //I am moving this remove call to MmfStorageProvide 'Insert' methods ....
                //}
                info = newInfo;
            }

            return(info);
        }
示例#2
0
        /// <summary>
        /// Gets the object from the memory mapped file.
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public byte[] Get(MmfObjectPtr info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            if (!info.View.IsOpen)
            {
                _viewManager.OpenView(info.View);
            }

            byte[] item = info.Arena.GetMemContents();
            info.View.Usage++;

            return(item);
        }
示例#3
0
        public byte[] Remove(MmfObjectPtr info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            if (!info.View.IsOpen)
            {
                _viewManager.OpenView(info.View);
            }

            byte[] item = info.Arena.GetMemContents();
            // Reclaim space for current item.

            info.View.DeAllocate(info.Arena);

            return(item);
        }