module Indexable(T)
Overview
Optimized extension for Indexable types (Array, Slice, etc.)
Included Modules
- Enumerable(T)
- Iterable(T)
Defined in:
parallel/indexable.crInstance Method Summary
-
#par_each(execution_context : Fiber::ExecutionContext::MultiThreaded | Nil = nil, *, chunk : Int32 | Nil = nil, &block : T -> _)
Optimized parallel each for indexable collections Uses robust error handling internally but maintains fail-fast behavior
-
#par_map(execution_context : Fiber::ExecutionContext::MultiThreaded | 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 but maintains fail-fast behavior
Instance methods inherited from module Enumerable(T)
par_each(execution_context : Fiber::ExecutionContext::MultiThreaded | Nil = nil, *, chunk : Int32 | Nil = nil, &block : T -> _)
par_each,
par_map(execution_context : Fiber::ExecutionContext::MultiThreaded | Nil = nil, *, chunk : Int32 | Nil = nil, &block : T -> U) forall U
par_map
Instance Method Detail
def par_each(execution_context : Fiber::ExecutionContext::MultiThreaded | Nil = nil, *, chunk : Int32 | Nil = nil, &block : T -> _)
#
Optimized parallel each for indexable collections Uses robust error handling internally but maintains fail-fast behavior
[1, 2, 3].par_each { |x| puts x }
[1, 2, 3, 4].par_each(chunk: 2) { |x| puts x } # same result, fewer context switches
def par_map(execution_context : Fiber::ExecutionContext::MultiThreaded | 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 but maintains fail-fast behavior
[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)