We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 05b8492 commit f409578Copy full SHA for f409578
lib/concurrent/actor/utils/broadcast.rb
@@ -4,7 +4,19 @@ module Concurrent
4
module Actor
5
module Utils
6
7
- # TODO doc
+ # Allows to build pub/sub easily.
8
+ # @example news
9
+ # news_channel = Concurrent::Actor::Utils::Broadcast.spawn :news
10
+
11
+ # 2.times do |i|
12
+ # Concurrent::Actor::Utils::AdHoc.spawn "listener-#{i}" do
13
+ # news_channel << :subscribe
14
+ # -> message { puts message }
15
+ # end
16
17
+ #
18
+ # news_channel << 'Ruby rocks!'
19
+ # # prints: 'Ruby rocks!' twice
20
class Broadcast < Context
21
22
def initialize
@@ -34,6 +46,7 @@ def filtered_receivers
34
46
@receivers
35
47
end
36
48
49
37
50
38
51
39
52
0 commit comments