Indexable(T)
Inherits Enumerable < Iterable
Optimized extension for Indexable types (Array, Slice, etc.)
Instance methods
par_each(execution_context : Fiber::ExecutionContext::Parallel | Nil = nil, *, chunk : Int32 | Nil = nil, &block : T -> _)
Optimized parallel each for indexable collections Uses robust error handling internally and propagates exceptions
[1, 2, 3].par_each { |x| puts x }
[1, 2, 3, 4].par_each(chunk: 2) { |x| puts x } # same result, fewer context switches
par_map(execution_context : Fiber::ExecutionContext::Parallel | Nil = nil, *, chunk : Int32 | Nil = nil, &block : T -> U) forall U
Optimized parallel map for indexable collections Uses unsafe_fetch for better performance and guarantees order preservation Uses robust error handling internally and propagates exceptions
[1, 2, 3, 4].par_map { |x| x * 2 } # => [2, 4, 6, 8]
[1, 2, 3, 4].par_map(chunk: 2) { |x| x * 2 } # => [2, 4, 6, 8] (same result, fewer context switches)