DoubleDown.Contract.Dispatch.Defer (double_down v0.56.0)

Copy Markdown View Source

A deferred execution marker.

When a handler or test double returns %DoubleDown.Contract.Dispatch.Defer{fun: fun}, the dispatch system releases the NimbleOwnership lock before calling fun.(). This avoids deadlocks when the deferred function makes further dispatched calls (e.g. transact calling insert inside its body).

For users of the Double API, prefer DoubleDown.Double.defer/1 over constructing this struct directly.

Used internally by Repo.Stub, Repo.OpenInMemory, and DoubleDown.Double's canonical handler.

Summary

Functions

Create a new Defer marker. Validates that fun is a 0-arity function.

Types

t()

@type t() :: %DoubleDown.Contract.Dispatch.Defer{fun: (-> term())}

Functions

new(fun)

@spec new((-> term())) :: t()

Create a new Defer marker. Validates that fun is a 0-arity function.