barrel_parallel (barrel_docdb v1.0.0)
View SourceParallel execution utilities for barrel_docdb
Provides bounded parallel map operations using a static worker pool. Workers are pre-spawned and reused, eliminating per-operation spawn overhead. Similar to PostgreSQL's background worker pool approach.
Summary
Functions
Get default number of workers (scheduler count)
Parallel filtermap with default concurrency
Parallel filtermap with bounded concurrency, preserves order
Parallel map with default concurrency
Parallel map with bounded concurrency, preserves order
Start the worker pool with default worker count
Start the worker pool with specified worker count
Stop the worker pool
Functions
-spec get_default_workers() -> pos_integer().
Get default number of workers (scheduler count)
Parallel filtermap with default concurrency
-spec pfiltermap(fun((A) -> boolean() | {true, B}), [A], pos_integer()) -> [B] when A :: term(), B :: term().
Parallel filtermap with bounded concurrency, preserves order
Parallel map with default concurrency
-spec pmap(fun((A) -> B), [A], pos_integer()) -> [B] when A :: term(), B :: term().
Parallel map with bounded concurrency, preserves order
Start the worker pool with default worker count
-spec start_link(pos_integer()) -> {ok, pid()} | {error, term()}.
Start the worker pool with specified worker count
-spec stop() -> ok.
Stop the worker pool