Class SnapshotParticipant<S>

java.lang.Object
fr.robie.machineengine.api.transfer.SnapshotParticipant<S>
Type Parameters:
S - an immutable snapshot of the participant's state
Direct Known Subclasses:
SingleVariantStorage

public abstract class SnapshotParticipant<S> extends Object
Base class for state that takes part in transactions (ARCHITECTURE.md ยง10.2). Call updateSnapshots(TransactionContext) before every change; the state is restored from the snapshot if the transaction aborts.
  • Constructor Details

    • SnapshotParticipant

      public SnapshotParticipant()
  • Method Details

    • createSnapshot

      @NotNull protected abstract S createSnapshot()
      Returns:
      an immutable copy of the current state
    • readSnapshot

      protected abstract void readSnapshot(@NotNull S snapshot)
      Restores state captured by createSnapshot().
    • onFinalCommit

      protected void onFinalCommit()
      Called once the outer transaction committed changes made to this participant.
    • updateSnapshots

      public final void updateSnapshots(@NotNull @NotNull TransactionContext transaction)
      Must be called before modifying state inside transaction.