Class: Bolt::Notifier
- Inherits:
-
Object
- Object
- Bolt::Notifier
- Defined in:
- lib/bolt/notifier.rb
Instance Method Summary collapse
-
#initialize(executor = nil) ⇒ Notifier
constructor
A new instance of Notifier.
- #notify(callback, event) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(executor = nil) ⇒ Notifier
Returns a new instance of Notifier.
5 6 7 8 9 10 |
# File 'lib/bolt/notifier.rb', line 5 def initialize(executor = nil) # lazy-load expensive gem code require 'concurrent' @executor = executor || Concurrent::SingleThreadExecutor.new end |
Instance Method Details
#notify(callback, event) ⇒ Object
12 13 14 15 16 |
# File 'lib/bolt/notifier.rb', line 12 def notify(callback, event) @executor.post do callback.call(event) end end |
#shutdown ⇒ Object
18 19 20 21 |
# File 'lib/bolt/notifier.rb', line 18 def shutdown @executor.shutdown @executor.wait_for_termination end |