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/keyed.rb,
lib/async/container/forked.rb,
lib/async/container/hybrid.rb,
lib/async/container/notify.rb,
lib/async/container/thread.rb,
lib/async/container/channel.rb,
lib/async/container/generic.rb,
lib/async/container/process.rb,
lib/async/container/version.rb,
lib/async/container/threaded.rb,
lib/async/container/controller.rb,
lib/async/container/statistics.rb,
lib/async/container/notify/pipe.rb,
lib/async/container/notify/client.rb,
lib/async/container/notify/server.rb,
lib/async/container/notify/socket.rb,
lib/async/container/notify/console.rb

Overview

Manages a reactor within one or more threads.

Defined Under Namespace

Modules: Notify Classes: Channel, Controller, Error, Forked, Generic, Group, Hybrid, InitializationError, Keyed, Process, Statistics, Terminate, Thread, Threaded

Constant Summary collapse

Interrupt =
::Interrupt
VERSION =
"0.16.4"

Class Method Summary collapse

Class Method Details

.best_container_classObject



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

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

.fork?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/async/container/best.rb', line 30

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

.new(*arguments) ⇒ Object



42
43
44
# File 'lib/async/container/best.rb', line 42

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.



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

def self.processor_count
  Etc.nprocessors
rescue
  2
end