All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.intellij.util.io.storage.Storage Maven / Gradle / Ivy

There is a newer version: 2.1.0-Beta1-1.0.25
Show newest version
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.io.storage;

import com.intellij.util.io.PagePool;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.nio.file.Path;

public class Storage extends AbstractStorage {
  public Storage(@NotNull Path path) throws IOException {
    super(path, true);
  }

  public Storage(@NotNull Path path, CapacityAllocationPolicy capacityAllocationPolicy) throws IOException {
    super(path, capacityAllocationPolicy);
  }

  @Override
  protected AbstractRecordsTable createRecordsTable(PagePool pool, @NotNull Path recordsFile) throws IOException {
    return new RecordsTable(recordsFile, pool);
  }

  public int createNewRecord() throws IOException {
    return withWriteLock(() -> {
      return myRecordsTable.createNewRecord();
    });
  }

  public void deleteRecord(int record) throws IOException {
    assert record > 0;
    withWriteLock(() -> {
      doDeleteRecord(record);
    });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy