@Override public boolean reserve(long size) throws IllegalArgumentException { if (size < 0) { throw new IllegalArgumentException(); } if (size > available()) { return false; } else { this.used += size; return true; } }
/** * Adds an off-heap resource of the given name to this registry. * * @param name the name of the resource * @param offHeapSize the off-heap size * @param unit the size unit type * @return {@code this} {@code OffHeapIdentifierRegistry} */ private OffHeapIdentifierRegistry addResource(String name, int offHeapSize, MemoryUnit unit) { this.pools.put(OffHeapResourceIdentifier.identifier(name), new TestOffHeapResource(unit.toBytes(offHeapSize))); return this; }