ExPool v0.1.1 ExPool.State.Stash

A stash of workers.

This module defines a ExPool.State.Stash struct and the main functions to manage workers in a pool.

Fields

  • sup - simple_one_for_one supervisor to start and supervise workers
  • workers - list of available workers

Summary

Functions

Returns the number of available workers

Get a worker and remove it from the workers list

Builds a new Stash struct with the given configuration

Add a worker to the workers list

Types

t :: %ExPool.State.Stash{workers: workers}
worker :: pid

Functions

available(stash)

Specs

available(t) :: non_neg_integer

Returns the number of available workers.

get(stash)

Specs

get(t) :: {:ok, {worker, t}} | {:empty, t}

Get a worker and remove it from the workers list.

new(opts)

Specs

new(opts :: [Keyword]) :: t

Builds a new Stash struct with the given configuration.

Configuration options

  • :worker_mod - (Required) worker module that fits on a supervision tree
return(stash, worker)

Specs

return(t, worker) :: t

Add a worker to the workers list.