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.



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

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

Instance Method Details

#execute_eventually(request) ⇒ Object



19
20
21
22
# File 'lib/wrest/async_request/thread_pool.rb', line 19

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

#join_pool_threads!Object



24
25
26
# File 'lib/wrest/async_request/thread_pool.rb', line 24

def join_pool_threads!
  @pool.wait_for_termination
end