ExecutionPlane.TaskSupport (execution_plane v0.1.0)

Copy Markdown View Source

Small task helpers shared by the runtime and transport layers.

Summary

Functions

Starts an unlinked task under the default task supervisor.

Starts an unlinked task under a specific task supervisor.

Awaits a task result using the Task.yield || Task.shutdown pattern.

Starts a child task under the default task supervisor.

Starts a child task under a specific task supervisor.

Types

task_start_error()

@type task_start_error() ::
  :noproc
  | {:runtime_not_started, :execution_plane_process}
  | {:task_start_failed, term()}

Functions

async_nolink(fun)

@spec async_nolink((-> any())) :: {:ok, Task.t()} | {:error, task_start_error()}

Starts an unlinked task under the default task supervisor.

async_nolink(supervisor, fun)

@spec async_nolink(pid() | atom(), (-> any())) ::
  {:ok, Task.t()} | {:error, task_start_error()}

Starts an unlinked task under a specific task supervisor.

await(task, timeout \\ 5000, shutdown \\ :brutal_kill)

@spec await(Task.t(), timeout(), :brutal_kill | :shutdown) ::
  {:ok, term()} | {:exit, term()} | {:error, :timeout}

Awaits a task result using the Task.yield || Task.shutdown pattern.

start_child(fun)

@spec start_child((-> any())) :: {:ok, pid()} | {:error, task_start_error()}

Starts a child task under the default task supervisor.

start_child(supervisor, fun)

@spec start_child(pid() | atom(), (-> any())) ::
  {:ok, pid()} | {:error, task_start_error()}

Starts a child task under a specific task supervisor.