Class: Contr::Async::Pool::Fixed

Inherits:
Base
  • Object
show all
Defined in:
lib/contr/async/pool/fixed.rb

Instance Method Summary collapse

Methods inherited from Base

#executor, #future, #zip

Constructor Details

#initialize(max_threads: Concurrent.processor_count) ⇒ Fixed

Returns a new instance of Fixed.



7
8
9
# File 'lib/contr/async/pool/fixed.rb', line 7

def initialize(max_threads: Concurrent.processor_count)
  @max_threads = max_threads
end

Instance Method Details

#create_executorObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/contr/async/pool/fixed.rb', line 11

def create_executor
  Concurrent::ThreadPoolExecutor.new(
    min_threads:     0,
    max_threads:     @max_threads,
    auto_terminate:  true,
    idletime:        60,           # 1 minute
    max_queue:       0,            # unlimited
    fallback_policy: :caller_runs  # doesn't matter - max_queue 0
  )
end