Class SnapshotSwapManager<T extends AutoCloseable>

java.lang.Object
org.impulsegraph.storage.csr.SnapshotSwapManager<T>
All Implemented Interfaces:
AutoCloseable

public class SnapshotSwapManager<T extends AutoCloseable> extends Object implements AutoCloseable
Generic thread-safe A/B pointer swap manager for off-heap graph containers (RelationSnapshot and GraphSnapshot). Tracks active readers per epoch so old off-heap Arenas can be safely closed.
  • Constructor Details

    • SnapshotSwapManager

      public SnapshotSwapManager(T initialResource)
    • SnapshotSwapManager

      public SnapshotSwapManager(T initialResource, long swapDrainTimeout, long closeDrainTimeout, TimeUnit unit, Consumer<Throwable> errorHandler)
  • Method Details

    • acquireCurrent

      public SnapshotSwapManager.Holder<T> acquireCurrent()
      Obtains the current resource and increments its reader reference count. The caller MUST invoke SnapshotSwapManager.Holder.release() when finished reading.
    • getCurrent

      public T getCurrent()
    • swap

      public void swap(T newResource)
      Atomically swaps the active resource to a new instance and schedules bounded draining and closing of the previous one.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable