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
- ASYNC_CONTAINER_PROCESSOR_COUNT =
'ASYNC_CONTAINER_PROCESSOR_COUNT'- VERSION =
"0.16.6"
Class Method Summary collapse
- .best_container_class ⇒ Object
- .fork? ⇒ Boolean
- .new(*arguments) ⇒ Object
-
.processor_count(env = ENV) ⇒ Integer
The processor count which may be used for the default number of container threads/processes.
Class Method Details
.best_container_class ⇒ Object
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
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_count(env = ENV) ⇒ Integer
The processor count which may be used for the default number of container threads/processes. You can override the value provided by the system by specifying the ASYNC_CONTAINER_PROCESSOR_COUNT environment variable.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/async/container/generic.rb', line 37 def self.processor_count(env = ENV) count = env.fetch(ASYNC_CONTAINER_PROCESSOR_COUNT) do Etc.nprocessors rescue 1 end.to_i if count < 1 raise RuntimeError, "Invalid processor count #{count}!" end return count end |