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 iterator_find_pmap(
input: Iterator(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 iterator.find_map
pub fn iterator_pmap(
input: Iterator(a),
mapping_func: fn(a) -> b,
num_workers: WorkerAmount,
timeout_milliseconds: Int,
) -> Iterator(Result(b, Nil))
This function behaves similarly to gleam_stdlib’s iterator.map
Creates an iterator from an existing iterator and a transformation function
Each element in the new iterator will be the result of calling the given function on the elements in the given iterator, 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 iterator.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 iterator is later run
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 iterator.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)