Class: Pool
- Inherits:
-
Object
- Object
- Pool
- Defined in:
- lib/gooddata_eloqua/helpers/pool.rb
Instance Attribute Summary collapse
-
#running ⇒ Object
Returns the value of attribute running.
Instance Method Summary collapse
- #active_threads ⇒ Object
- #exit ⇒ Object
-
#initialize ⇒ Pool
constructor
A new instance of Pool.
- #list ⇒ Object
- #thread(&thread) ⇒ Object (also: #fork)
Constructor Details
#initialize ⇒ Pool
5 6 7 8 |
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 5 def initialize @group = ThreadGroup.new @running = true end |
Instance Attribute Details
#running ⇒ Object
Returns the value of attribute running.
3 4 5 |
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 3 def running @running end |
Instance Method Details
#active_threads ⇒ Object
16 17 18 |
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 16 def active_threads @group.list.length end |
#exit ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 24 def exit @group.pmap { |thread| thread.exit } unless @group.empty? end |
#list ⇒ Object
20 21 22 |
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 20 def list @group.list end |
#thread(&thread) ⇒ Object Also known as: fork
10 11 12 |
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 10 def thread(&thread) @group.add(Thread.new(&thread)) end |