Method: Garcon::RubySingleThreadExecutor#initialize

Defined in:
lib/garcon/task/single_thread_executor.rb

#initialize(opts = {}) ⇒ RubySingleThreadExecutor

Create a new thread pool.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :fallback_policy (Symbol) — default: :discard

    The policy for handling new tasks that are received when the queue size has reached ‘max_queue` or after the executor has shut down.



34
35
36
37
38
39
40
41
42
43
# File 'lib/garcon/task/single_thread_executor.rb', line 34

def initialize(opts = {})
  @queue  = Queue.new
  @thread = nil
  @fallback_policy = opts.fetch(:fallback_policy, :discard)
  if !FALLBACK_POLICY.include?(fallback)
    raise ArgumentError, "#{fallback} is not a valid fallback policy"
  end
  init_executor
  enable_at_exit_handler!(opts)
end