broadcast

package
v0.0.0-...-29a3764 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

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

View Source
const (
	// WATCHED ...
	WATCHED = iota
)

Variables

View Source
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 NewLocalBroadcaster

func NewLocalBroadcaster() *Broadcaster

NewLocalBroadcaster ...

func (*Broadcaster) Broadcast

func (b *Broadcaster) Broadcast(v interface{})

Broadcast ...

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) Signal

func (b *Broadcaster) Signal()

Signal ...

func (*Broadcaster) Write

func (b *Broadcaster) Write(v interface{})

Write a value to all listening receivers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL