Class: Wrest::AsyncRequest::ThreadPool

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

Instance Method Summary collapse

Constructor Details

#initialize(number_of_threads) ⇒ ThreadPool

Returns a new instance of ThreadPool.



13
14
15
# File 'lib/wrest/async_request/thread_pool.rb', line 13

def initialize(number_of_threads)
  @pool = Concurrent::FixedThreadPool.new(number_of_threads)
end

Instance Method Details

#execute_eventually(request) ⇒ Object



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

def execute_eventually(request)
  @pool.post { request.invoke }
  nil
end

#join_pool_threads!Object



22
23
24
# File 'lib/wrest/async_request/thread_pool.rb', line 22

def join_pool_threads!
  @pool.wait_for_termination
end