Class: Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata_eloqua/helpers/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePool



5
6
7
8
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 5

def initialize
  @group = ThreadGroup.new
  @running = true
end

Instance Attribute Details

#runningObject

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_threadsObject



16
17
18
# File 'lib/gooddata_eloqua/helpers/pool.rb', line 16

def active_threads
  @group.list.length
end

#exitObject



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

#listObject



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