View Source Lightning.TaskWorker (Lightning v2.10.4)

A TaskWorker with concurrency limits.

A simple concurrency limiter that wraps Task.Supervisor, which already does have the ability to specify max_children; it throws an error when that limit is exceeded.

To use it, start it like any other process; ideally in your supervision tree.

  ...,
  {Lightning.TaskWorker, name: :cli_task_worker, max_tasks: 4}

Options

  • :max_tasks Defaults to the number of system schedulers available to the vm.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

start_link(opts \\ [name: nil])

View Source
@spec start_task(worker :: GenServer.name(), (-> any())) ::
  {:error, :too_many_processes} | term()