Parallel Stream v1.0.6 ParallelStream.Each
The each iterator implementation
Summary
Functions
Creates a stream that will apply the given function on enumeration in parallel. The functions return value will be thrown away, hence this is useful for producing side-effects
Functions
Creates a stream that will apply the given function on enumeration in parallel. The functions return value will be thrown away, hence this is useful for producing side-effects.
Options
These are the options:
:num_workers
– The number of parallel operations to run when running the stream.:worker_work_ratio
– The available work per worker, defaults to 5. Higher rates will mean more work sharing, but might also lead to work fragmentation slowing down the queues.
Examples
Iterate and write the numbers to stdout:
iex> parallel_stream = 1..5 |> ParallelStream.each(&IO.write/1)
iex> parallel_stream |> Stream.run
:ok # 12345 appears on stdout