parallel_map
Types
This type is used to specify the number of workers to spawn
pub type WorkerAmount {
WorkerAmount(value: Int)
MatchSchedulersOnline
}
Constructors
-
WorkerAmount(value: Int)
will spawn that number of workers
-
MatchSchedulersOnline
will spawn workers to match the amount of schedulers currently online
Functions
pub fn list_find_pmap(
input: List(a),
mapping_func: fn(a) -> Result(b, c),
num_workers: WorkerAmount,
timeout_milliseconds: Int,
) -> Result(b, Nil)
This function behaves similarly to gleam_stdlib’s list.find_map
pub fn list_pmap(
input: List(a),
mapping_func: fn(a) -> b,
num_workers: WorkerAmount,
timeout_milliseconds: Int,
) -> List(Result(b, Nil))
This function behaves similarly to gleam_stdlib’s yielder.map
Returns a new list containing only the elements of the first list after the function has been applied to each one, with the resulting value wrapped in a Result
If the timeout specified is exceeded while attempting to collect the result of the computation, the value will instead be Error(Nil)
pub fn yielder_find_pmap(
input: Yielder(a),
mapping_func: fn(a) -> Result(b, c),
num_workers: WorkerAmount,
timeout_milliseconds: Int,
) -> Result(b, Nil)
This function behaves similarly to gleam_stdlib’s yielder.find_map
pub fn yielder_pmap(
input: Yielder(a),
mapping_func: fn(a) -> b,
num_workers: WorkerAmount,
timeout_milliseconds: Int,
) -> Yielder(Result(b, Nil))
This function behaves similarly to gleam/yielder’s yielder.map
Creates an yielder from an existing yielder and a transformation function
Each element in the new yielder will be the result of calling the given function on the elements in the given yielder, with the resulting value wrapped in a Result
If the timeout specified is exceeded while attempting to collect the result of the computation, the element will instead be Error(Nil)
This function also differs from yielder.map in that it will spawn the workers and perform the computation right when it is called, but it does not attempt to collect the result until the yielder is later run