예제 #1
0
 @NotNull
 private static NativeBytesStore<Void> of(long capacity, boolean zeroOut, boolean elastic)
     throws IllegalArgumentException {
   Memory memory = OS.memory();
   long address = memory.allocate(capacity);
   if (zeroOut || capacity < MEMORY_MAPPED_SIZE) {
     memory.setMemory(address, capacity, (byte) 0);
     memory.storeFence();
   }
   Deallocator deallocator = new Deallocator(address, capacity);
   return new NativeBytesStore<>(address, capacity, deallocator, elastic);
 }
예제 #2
0
  @NotNull
  @Override
  @ForceInline
  public NativeBytesStore<Underlying> zeroOut(long start, long end)
      throws IllegalArgumentException {
    if (start < writePosition() || end > writeLimit())
      throw new IllegalArgumentException(
          "position: "
              + writePosition()
              + ", start: "
              + start
              + ", end: "
              + end
              + ", limit: "
              + writeLimit());
    if (start >= end) return this;

    memory.setMemory(address + translate(start), end - start, (byte) 0);
    return this;
  }