Class: Legion::Dispatch::Local
- Inherits:
-
Object
- Object
- Legion::Dispatch::Local
- Defined in:
- lib/legion/dispatch/local.rb
Instance Method Summary collapse
- #capacity ⇒ Object
-
#initialize(pool_size: nil) ⇒ Local
constructor
A new instance of Local.
- #start ⇒ Object
- #stop ⇒ Object
- #submit(&block) ⇒ Object
Constructor Details
Instance Method Details
#capacity ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/legion/dispatch/local.rb', line 31 def capacity { pool_size: @pool.max_length, queue_length: @pool.queue_length, running: @pool.running? } end |
#start ⇒ Object
13 |
# File 'lib/legion/dispatch/local.rb', line 13 def start; end |
#stop ⇒ Object
24 25 26 27 28 29 |
# File 'lib/legion/dispatch/local.rb', line 24 def stop return unless @pool.running? @pool.shutdown @pool.wait_for_termination(15) end |
#submit(&block) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/legion/dispatch/local.rb', line 15 def submit(&block) @pool.post do block.call rescue StandardError => e Legion::Logging.error "[Dispatch::Local] #{e.}" if defined?(Legion::Logging) Legion::Logging.debug e.backtrace&.first(5) if defined?(Legion::Logging) end end |