Class: Sink::Multicast

Inherits:
Object show all
Includes:
Sink
Defined in:
lib/coroutines/sink.rb

Overview

Collects multiple sinks into a multicast group. Every input value of the multicast group is supplied to each of its members. When the multicast group is closed, all members are closed as well.

Instance Method Summary collapse

Methods included from Sink

#<=, #input_map, #input_reduce, #input_reject, #input_select

Constructor Details

#initialize(*receivers) ⇒ Multicast

Returns a new instance of Multicast.



76
77
78
# File 'lib/coroutines/sink.rb', line 76

def initialize(*receivers)
	@receivers = receivers
end

Instance Method Details

#<<(obj) ⇒ Object



79
80
81
82
# File 'lib/coroutines/sink.rb', line 79

def <<(obj)
	@receivers.each { |r| r << obj }
	self
end

#closeObject



83
84
85
# File 'lib/coroutines/sink.rb', line 83

def close
	@receivers.each(&:close)
end