Class: Concurrent::Actor::Utils::Broadcast
- Inherits:
-
RestartingContext
- Object
- AbstractContext
- RestartingContext
- Concurrent::Actor::Utils::Broadcast
- Defined in:
- lib/concurrent-ruby-edge/concurrent/actor/utils/broadcast.rb
Overview
Allows to build pub/sub easily.
Instance Method Summary collapse
-
#filtered_receivers ⇒ undocumented
override to define different behaviour, filtering etc.
-
#initialize ⇒ Broadcast
constructor
A new instance of Broadcast.
- #on_message(message) ⇒ undocumented
Constructor Details
Instance Method Details
#filtered_receivers ⇒ undocumented
override to define different behaviour, filtering etc
46 47 48 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/utils/broadcast.rb', line 46 def filtered_receivers @receivers end |
#on_message(message) ⇒ undocumented
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/concurrent-ruby-edge/concurrent/actor/utils/broadcast.rb', line 27 def () case when :subscribe if envelope.sender.is_a? Reference @receivers.add envelope.sender true else false end when :unsubscribe !!@receivers.delete(envelope.sender) when :subscribed? @receivers.include? envelope.sender else filtered_receivers.each { |r| r << } end end |