class Garcon::RubySingleThreadExecutor

Public Class Methods

new(opts = {}) click to toggle source

Create a new thread pool.

@option opts [Symbol] :fallback_policy (: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.
# 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