Documentation
¶
Overview ¶
Package broadcast implements broadcast type messaging (or event) in a Go idiomatic way. This is based on the design invented at [1] and the actual implementation from [2], modified to only expose channels, which are the prefered way of communicating in Go.
The comments are orignally from the gibb package.
[1] http://rogpeppe.wordpress.com/2009/12/01/concurrent-idioms-1-broadcasting-values-in-go-with-linked-channels/ [2] https://github.com/dagoof/gibb
Index ¶
Constants ¶
const ( // WATCHED ... WATCHED = iota )
Variables ¶
var ( // Closer is a global shutdown closer. Closer event.Event )
var LocalBroadcasters = map[int]*Broadcaster{}
LocalBroadcasters ...
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
Broadcaster provides Receivers that can be read from. Every value that is written to a broadcaster will be sent to any active Receivers. No messages are dropped, and are delivered in order. Receivers that fail to keep up with producers can oom your system because no messages are dropped.
func NewBroadcaster ¶
func NewBroadcaster() *Broadcaster
NewBroadcaster creates a new broadcaster with the necessary internal structure. The uninitialized broadcaster is unsuitable to be listened or written to.
func (*Broadcaster) Close ¶
func (b *Broadcaster) Close()
Close Closes the broadcaster, this also closes all the listening channels.
func (*Broadcaster) Listen ¶
func (b *Broadcaster) Listen() (<-chan interface{}, chan<- interface{})
Listen creates a receiver that can read written values.
func (*Broadcaster) Write ¶
func (b *Broadcaster) Write(v interface{})
Write a value to all listening receivers.