Class: Async::Container::Generic
- Inherits:
-
Object
- Object
- Async::Container::Generic
- Defined in:
- lib/async/container/generic.rb
Instance Attribute Summary collapse
-
#statistics ⇒ Object
readonly
Returns the value of attribute statistics.
Instance Method Summary collapse
- #async(**options, &block) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize ⇒ Generic
constructor
A new instance of Generic.
- #run(count: Container.processor_count, **options, &block) ⇒ Object
Constructor Details
#initialize ⇒ Generic
Returns a new instance of Generic.
35 36 37 |
# File 'lib/async/container/generic.rb', line 35 def initialize @statistics = Statistics.new end |
Instance Attribute Details
#statistics ⇒ Object (readonly)
Returns the value of attribute statistics.
39 40 41 |
# File 'lib/async/container/generic.rb', line 39 def statistics @statistics end |
Instance Method Details
#async(**options, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/async/container/generic.rb', line 45 def async(**, &block) spawn(**) do |instance| begin Async::Reactor.run(instance, &block) rescue Interrupt # Graceful exit. end end end |
#failed? ⇒ Boolean
41 42 43 |
# File 'lib/async/container/generic.rb', line 41 def failed? @statistics.failed? end |
#run(count: Container.processor_count, **options, &block) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/async/container/generic.rb', line 55 def run(count: Container.processor_count, **, &block) count.times do async(**, &block) end return self end |