Interface TransactionContext

All Known Subinterfaces:
Transaction

@NonExtendable public interface TransactionContext
The transaction an operation runs in (ARCHITECTURE.md §10.2, D11). Operations take a context rather than a Transaction so they cannot commit or abort it themselves.

A transaction and everything done inside it belongs to the thread that opened it.

  • Method Details

    • nestingDepth

      int nestingDepth()
      0 for the outer transaction, 1 for its first nested transaction, …
    • parent

      @Nullable @Nullable TransactionContext parent()
      Returns:
      the enclosing transaction, or null for the outer one
    • openNested

      @NotNull @NotNull Transaction openNested()
      Opens a transaction nested in this one. Its changes are undone if it aborts, and become part of this transaction if it commits.
      Throws:
      IllegalStateException - if this is not the innermost open transaction
    • addCloseCallback

      void addCloseCallback(@NotNull @NotNull TransactionContext.CloseCallback callback)
      Called when this transaction closes, in reverse registration order.
    • onCommit

      void onCommit(@NotNull @NotNull Runnable action)
      Runs action once the outer transaction has committed, if every transaction between this one and the outer one committed too. Dropped on any abort. Use it for side effects such as wake-ups, events and dirty marking.