Module: Async::Container

Defined in:
lib/async/container.rb,
lib/async/container/best.rb,
lib/async/container/error.rb,
lib/async/container/group.rb,
lib/async/container/forked.rb,
lib/async/container/hybrid.rb,
lib/async/container/generic.rb,
lib/async/container/version.rb,
lib/async/container/threaded.rb,
lib/async/container/controller.rb,
lib/async/container/statistics.rb

Overview

Manages a reactor within one or more threads.

Defined Under Namespace

Classes: ContainerFailed, Controller, Error, Forked, Generic, Group, Hybrid, Statistics, Threaded

Constant Summary collapse

VERSION =
"0.15.0"

Class Method Summary collapse

Class Method Details

.best_container_classObject



32
33
34
35
36
37
38
# File 'lib/async/container/best.rb', line 32

def self.best_container_class
  if fork?
    return Forked
  else
    return Threaded
  end
end

.fork?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/async/container/best.rb', line 28

def self.fork?
  Process.respond_to?(:fork) and Process.respond_to?(:setpgid)
end

.new(*arguments) ⇒ Object



40
41
42
# File 'lib/async/container/best.rb', line 40

def self.new(*arguments)
  best_container_class.new(*arguments)
end

.processor_countInteger

Returns the number of hardware processors which can run threads/processes simultaneously.

Returns:

  • (Integer)

    the number of hardware processors which can run threads/processes simultaneously.



28
29
30
31
32
# File 'lib/async/container/generic.rb', line 28

def self.processor_count
  Etc.nprocessors
rescue
  2
end