123456789_123456789_123456789_123456789_123456789_

Module: Concurrent::Options

Relationships & Source Files
Defined in: lib/concurrent-ruby/concurrent/options.rb

Class Method Summary

Class Method Details

.executor(executor_identifier)

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/options.rb', line 27

def self.executor(executor_identifier)
  case executor_identifier
  when :fast
    Concurrent.global_fast_executor
  when :io
    Concurrent.global_io_executor
  when :immediate
    Concurrent.global_immediate_executor
  when Concurrent::ExecutorService
    executor_identifier
  else
    raise ArgumentError, "executor not recognized by '#{executor_identifier}'"
  end
end

.executor_from_options(opts = {}) ⇒ Executor? (private)

This method is for internal use only.

Get the requested Executor based on the values set in the options hash.

Parameters:

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

    the options defining the requested executor

Options Hash (opts):

  • :executor (Executor)

    when set use the given Executor instance. Three special values are also supported: :fast returns the global fast executor, :io returns the global io executor, and :immediate returns a new ImmediateExecutor object.

Returns:

  • (Executor, nil)

    the requested thread pool, or nil when no option specified

[ GitHub ]

  
# File 'lib/concurrent-ruby/concurrent/options.rb', line 19

def self.executor_from_options(opts = {}) # :nodoc:
  if identifier = opts.fetch(:executor, nil)
    executor(identifier)
  else
    nil
  end
end