Пример #1
0
 protected virtual void Clear(IFreespaceManager freespaceManager)
 {
     Slot slot = null;
     do
     {
         slot = freespaceManager.AllocateSlot(1);
     } while (slot != null);
     Assert.AreEqual(0, freespaceManager.SlotCount());
     Assert.AreEqual(0, freespaceManager.TotalFreespace());
 }
        public virtual Slot AllocateSlot(int length)
        {
            Slot slot = _delegate.AllocateSlot(_blockConverter.BytesToBlocks(length));

            if (slot == null)
            {
                return(null);
            }
            return(_blockConverter.ToNonBlockedLength(slot));
        }
        protected virtual void Clear(IFreespaceManager freespaceManager)
        {
            Slot slot = null;

            do
            {
                slot = freespaceManager.AllocateSlot(1);
            }while (slot != null);
            Assert.AreEqual(0, freespaceManager.SlotCount());
            Assert.AreEqual(0, freespaceManager.TotalFreespace());
        }
        public virtual Slot AllocateSlot(int length)
        {
            if (length <= 0)
            {
                throw new ArgumentException();
            }
            if (_freespaceManager != null && _freespaceManager.IsStarted())
            {
                Slot slot = _freespaceManager.AllocateSlot(length);
                if (slot != null)
                {
                    if (DTrace.enabled)
                    {
                        DTrace.GetSlot.LogLength(slot.Address(), slot.Length());
                    }
                    return(slot);
                }
                while (GrowDatabaseByConfiguredSize())
                {
                    slot = _freespaceManager.AllocateSlot(length);
                    if (slot != null)
                    {
                        if (DTrace.enabled)
                        {
                            DTrace.GetSlot.LogLength(slot.Address(), slot.Length());
                        }
                        return(slot);
                    }
                }
            }
            Slot appendedSlot = AppendBytes(length);

            if (DTrace.enabled)
            {
                DTrace.GetSlot.LogLength(appendedSlot.Address(), appendedSlot.Length());
            }
            return(appendedSlot);
        }