Method: Bosh::ThreadPool#process

Defined in:
lib/common/thread_pool.rb

#process(&block) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/common/thread_pool.rb', line 43

def process(&block)
  @lock.synchronize do
    @actions << block
    if @state == :open
      if @available_threads > 0
        @logger.debug('Creating new thread')
        @available_threads -= 1
        create_thread
      else
        @logger.debug('All threads are currently busy, queuing action')
      end
    elsif @state == :paused
      @logger.debug('Pool is paused, queueing action')
    end
  end
end