ExPool v0.1.1 ExPool.State
The internal state of the pool.
This module defines a ExPool.State
struct and the main functions
for working with pool internal state.
Fields
stash
- stash of available workersmonitors
- store for the monitored referencesqueue
- queue to store the waiting requests
Summary
Functions
Stores the given item and its associated reference
Returns the number of available workers
Adds an item to the queue
Gets a worker from the pool if there is any available
Gets an item from its reference
Keeps on the queue only items for those the function is true
Creates a new pool state with the given configuration
Pops an item from the queue
Returns the number of waiting processes
Gets a reference from its item
Removes the given item and its associated reference
Returns a worker to the pool
Returns the total number of workers
Types
Functions
Stores the given item and its associated reference.
Specs
available_workers(t) :: non_neg_integer
Returns the number of available workers.
Gets a worker from the pool if there is any available.
Gets an item from its reference.
Keeps on the queue only items for those the function is true.
Specs
new(opts :: [Keyword]) :: t
Creates a new pool state with the given configuration.
Configuration options
:worker_mod
- (Required) The worker module. It has to fit in a supervision tree (like a GenServer).:size
- (Optional) The size of the pool (default 5).
Pops an item from the queue.
Gets a reference from its item.
Removes the given item and its associated reference.