示例#1
0
        protected BaseReference AllocateAndPin(IStorable obj, int initialSize)
        {
            Global.Tracer.Assert(obj != null, "Cannot allocate reference to null");
            BaseReference baseReference = CreateReference(obj);

            baseReference.Init(this, GenerateTempId());
            CacheItem(baseReference, obj, fromDeserialize: false, initialSize);
            baseReference.PinValue();
            return(baseReference);
        }
示例#2
0
        public sealed override IReference <T> GenerateFixedReference <T>(T obj)
        {
            BaseReference baseReference = CreateReference(obj);

            baseReference.Init(this, GenerateTempId());
            ItemHolder itemHolder = new ItemHolder();

            itemHolder.Reference  = baseReference;
            itemHolder.Item       = obj;
            baseReference.Item    = itemHolder;
            baseReference.InQueue = InQueueState.InQueue;
            return((IReference <T>)baseReference);
        }
        public override IReference <T> GenerateFixedReference <T>(T obj)
        {
            BaseReference baseReference = CreateReference(obj);

            baseReference.Init(this, m_offsetMap.GenerateTempId());
            StorageItem storageItem = (StorageItem)(baseReference.Item = new StorageItem(baseReference.Id, -1, obj, ItemSizes.SizeOf(obj)));

            storageItem.AddReference(baseReference);
            storageItem.InQueue         = InQueueState.Exempt;
            storageItem.HasBeenUnPinned = true;
            (obj as ISelfReferential)?.SetReference(baseReference);
            return((IReference <T>)baseReference);
        }
        private IReference <T> InternalAllocate <T>(T obj, int priority, bool startPinned, int initialSize) where T : IStorable
        {
            Global.Tracer.Assert(obj != null, "Cannot allocate reference to null");
            BaseReference baseReference = CreateReference(obj);

            baseReference.Init(this, m_offsetMap.GenerateTempId());
            CacheItem(baseReference, obj, priority, initialSize);
            if (startPinned)
            {
                baseReference.PinValue();
            }
            return((IReference <T>)baseReference);
        }