Class: Forkit::Enumerable
- Inherits:
-
Object
- Object
- Forkit::Enumerable
- Defined in:
- lib/forkit/enumerable.rb
Overview
The enumerable allows for concurrent processing via JDK7's ForkJoinPool.
Instance Attribute Summary (collapse)
- - (Object) objects readonly
- - (Object) threshold readonly
Instance Method Summary (collapse)
-
- (nil) each(&block)
Execute the provided block for each element in the array.
-
- (Forkit::Enumerable) initialize(objects, threshold)
constructor
Instantiate the new concurrent enumerable.
Constructor Details
- (Forkit::Enumerable) initialize(objects, threshold)
Instantiate the new concurrent enumerable.
24 25 26 |
# File 'lib/forkit/enumerable.rb', line 24 def initialize(objects, threshold) @objects, @threshold = objects, threshold end |
Instance Attribute Details
- (Object) objects (readonly)
11 12 13 |
# File 'lib/forkit/enumerable.rb', line 11 def objects @objects end |
- (Object) threshold (readonly)
11 12 13 |
# File 'lib/forkit/enumerable.rb', line 11 def threshold @threshold end |
Instance Method Details
- (nil) each(&block)
Execute the provided block for each element in the array.
38 39 40 41 42 43 44 |
# File 'lib/forkit/enumerable.rb', line 38 def each(&block) if block_given? ForkJoinPool.new.invoke(Iterator.new(objects, threshold, block)) else objects.each end end |