WaitForIt.Waitable protocol (WaitForIt v2.2.0)

Copy Markdown View Source

Protocol used for evaluating waitable expressions against waiting conditions to determine if waiting should continue or halt with a final value.

Summary

Types

t()

All the types that implement this protocol.

Functions

Evaluates the waitable expression to provide its value, or to continue to wait.

Provides the final value of the waitable expression in the event of a timeout.

Types

t()

@type t() :: term()

All the types that implement this protocol.

value()

@type value() :: any()

wait_type()

@type wait_type() :: atom()

Functions

evaluate(waitable, env)

@spec evaluate(t(), Macro.Env.t()) :: {:halt, value()} | {:cont, value()}

Evaluates the waitable expression to provide its value, or to continue to wait.

It should return {:halt, value} if the wait is over and the final value of the waitable expression has been determined, or {:cont, value} if waiting should continue.

handle_timeout(waitable, last_value, env)

@spec handle_timeout(t(), value(), Macro.Env.t()) :: value()

Provides the final value of the waitable expression in the event of a timeout.

wait_type(waitable)

@spec wait_type(t()) :: wait_type()