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