Class PowerOfTwoAllocator

  • All Implemented Interfaces:
    java.lang.Iterable<Region>, java.util.Collection<Region>, java.util.Set<Region>, java.util.SortedSet<Region>

    public class PowerOfTwoAllocator
    extends AATreeSet<Region>
    An augmented AA tree allocator with unusual alignment/allocation properties.

    This allocator allocates only power-of-two size chunks. In addition these chunks are then only allocated on alignment with their own size. Hence a chunk of 2n size can only be allocated to an address satisfying a=2nx where x is an integer.

    • Field Detail

      • DEBUG

        private static final boolean DEBUG
      • VALIDATING

        private static final boolean VALIDATING
      • size

        private final int size
    • Constructor Detail

      • PowerOfTwoAllocator

        public PowerOfTwoAllocator​(int size)
        Create a power-of-two allocator with the given initial 'free' size area.
        Parameters:
        size - initial free size
    • Method Detail

      • free

        public void free​(int address,
                         int length)
      • tryFree

        public void tryFree​(int address,
                            int length)
      • claim

        public void claim​(int address,
                          int size)
      • occupied

        public int occupied()
      • free

        private void free​(Region r)
      • tryFree

        private boolean tryFree​(Region r)
      • insert

        private void insert​(Region x)
        Insert into the tree.
        Parameters:
        x - the item to insert.
      • tryInsert

        private boolean tryInsert​(Region x)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<Region>
      • validateFreeSpace

        private void validateFreeSpace()