Skip to content

keroro520/broadcast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Discription

Simple broadcast model with linked channels, based on broadcasting-values-in-go-with-linked-channels

Usage

  • Broadcast

      type Broadcaster struct {
          // the newest broadcast channel
      	cc    chan broadcast
          // a channel for sending messages
      	sendc chan<- interface{}
      }
    

func NewBroadcaster() Broadcaster returns a new broadcaster

func (b Broadcaster) Register() Receiver returns a Reciever that listens to b

func (b Broadcaster) Write(v interface{}) writes a massage v and publishes to all receivers

  • Receiver

      type Receiver struct {
      	c chan broadcast
      }
    

func (r *Receiver) Read() interface{} reads a message from broadcast which rigistered to before.

About

Simple broadcast model with linked channels

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages