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