Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Communication ¶
type Communication struct {
// contains filtered or unexported fields
}
func Init ¶
func Init() *Communication
Example ¶
package main import ( "fmt" "sync" "simonwaldherr.de/go/golibs/channel" ) func main() { var w sync.WaitGroup var receiver = make(map[int]chan interface{}) w.Add(5) con := channel.Init() for i := 0; i < 5; i++ { receiver[i] = con.AddReceiver() go func(j int) { fmt.Println(<-receiver[j]) w.Done() }(i) } transmitter01 := con.AddTransmitter() transmitter01 <- "Hello World" w.Wait() for i := 0; i < 5; i++ { con.CloseReceiver(receiver[i]) } }
Output: Hello World Hello World Hello World Hello World Hello World
func (*Communication) AddReceiver ¶
func (hub *Communication) AddReceiver() chan interface{}
func (*Communication) AddTransmitter ¶
func (hub *Communication) AddTransmitter() chan<- interface{}
func (*Communication) CloseReceiver ¶
func (hub *Communication) CloseReceiver(ch chan interface{}) int
func (*Communication) CountReceiver ¶
func (hub *Communication) CountReceiver() int
Click to show internal directories.
Click to hide internal directories.