Class: LimitedRed::ThreadPool

Inherits:
Object
  • Object
show all
Defined in:
lib/limited_red/thread_pool.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.threads=(value) ⇒ Object (writeonly)

Sets the attribute threads

Parameters:

  • value

    the value to set the attribute threads to.



15
16
17
# File 'lib/limited_red/thread_pool.rb', line 15

def threads=(value)
  @threads = value
end

Class Method Details

.wait_for_all_threads_to_finishObject



22
23
24
25
26
27
28
29
30
# File 'lib/limited_red/thread_pool.rb', line 22

def wait_for_all_threads_to_finish
  (@threads||[]).each do |thread|
    begin
      thread.join
    rescue
      puts "[Limited Red] Error trying to post results to Limited Red: #{$!}"
    end
  end
end

.with_a_thread_run(&block) ⇒ Object



17
18
19
20
# File 'lib/limited_red/thread_pool.rb', line 17

def with_a_thread_run(&block)
  @threads ||= []
  @threads << Thread.new(&block)
end