Method: Contender::Pool::PoolExecutor#initialize

Defined in:
lib/contender/pool/pool_executor.rb

#initialize(core_size, maximum_size, work_timeout, queue, thread_factory) ⇒ undefined

Raises:

  • (ArgumentError)

    If the core size is less than zero

  • (ArgumentError)

    If the maximum size is less than one or less than the core size

  • (ArgumentError)

    If the work timeout is less than zero



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/contender/pool/pool_executor.rb', line 48

def initialize(core_size, maximum_size, work_timeout, queue, thread_factory)
  raise ArgumentError if core_size < 0
  raise ArgumentError if maximum_size <= 0 || maximum_size < core_size
  raise ArgumentError if work_timeout < 0

  @queue = queue
  @thread_factory = thread_factory
  @rejection_policy = AbortPolicy.new

  @core_size = core_size
  @maximum_size = maximum_size
  @allow_core_timeout = false
  @work_timeout = work_timeout

  @control = Atomic.new(control_for(RUNNING, 0))

  @monitor = Monitor.new
  @termination = @monitor.new_cond

  # The following instance variables are guarded by the monitor
  @workers = Set.new

  @largest_size = 0
  @completed_task_count = 0
end