Exemplo n.º 1
0
        // Do nothing.
        // The RAM manager frees itself on reading.
        public override Slot AllocateSlot(int length)
        {
            _finder._key    = length;
            _finder._object = null;
            _freeBySize     = FreeSlotNode.RemoveGreaterOrEqual((FreeSlotNode)_freeBySize, _finder
                                                                );
            if (_finder._object == null)
            {
                return(null);
            }
            FreeSlotNode node = (FreeSlotNode)_finder._object;

            _listener.SlotRemoved(node._key);
            int blocksFound = node._key;
            int address     = node._peer._key;

            _freeByAddress = _freeByAddress.RemoveNode(node._peer);
            int remainingBlocks = blocksFound - length;

            if (SplitRemainder(remainingBlocks))
            {
                AddFreeSlotNodes(address + length, remainingBlocks);
            }
            else
            {
                length = blocksFound;
            }
            if (DTrace.enabled)
            {
                DTrace.FreespacemanagerGetSlot.LogLength(address, length);
            }
            return(new Slot(address, length));
        }
Exemplo n.º 2
0
 // do nothing
 // reading happens in start( )
 private void RemoveSlot(Slot slot)
 {
     _slotsByLength.Remove(Transaction(), slot);
     _slotsByAddress.Remove(Transaction(), slot);
     _listener.SlotRemoved(slot.Length());
 }