Sha256: f0d03d4e7117ee987f33eb107a7d560cf5c5d96da190077ea6115017af782a3b

Contents?: true

Size: 1.25 KB

Versions: 277

Compression:

Stored size: 1.25 KB

Contents

require 'concurrent/configuration'

module Concurrent

  # @!visibility private
  module Options

    # Get the requested `Executor` based on the values set in the options hash.
    #
    # @param [Hash] opts the options defining the requested executor
    # @option 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.
    #
    # @return [Executor, nil] the requested thread pool, or nil when no option specified
    #
    # @!visibility private
    def self.executor_from_options(opts = {}) # :nodoc:
      if identifier = opts.fetch(:executor, nil)
        executor(identifier)
      else
        nil
      end
    end

    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
  end
end

Version data entries

277 entries across 256 versions & 48 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
concurrent-ruby-1.1.6.pre1 lib/concurrent-ruby/concurrent/options.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.4/lib/concurrent/options.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/concurrent-ruby-1.1.3/lib/concurrent/options.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/concurrent-ruby-1.1.5/lib/concurrent/options.rb