diff options
Diffstat (limited to 'gochan.go')
| -rw-r--r-- | gochan.go | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -7,9 +7,9 @@ import ( "fmt" "sync" - "go.wit.com/log" "go.wit.com/gui/gui" - "go.wit.com/gui/gadgets" + "go.wit.com/lib/gadgets" + "go.wit.com/log" ) var debugWG *sync.WaitGroup @@ -24,8 +24,8 @@ func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow { g = w.Box().NewGroup("Channel stuff").Pad() // var debugWG sync.WaitGroup - g.NewButton("init()", func () { - if (debugNumberChan == nil) { + g.NewButton("init()", func() { + if debugNumberChan == nil { log.Log(CHAN, "making debugNumberChan channel") debugNumberChan = make(chan int) } else { @@ -33,35 +33,35 @@ func DebugGoChannels(p *gui.Node) *gadgets.BasicWindow { } debugWG = new(sync.WaitGroup) }) - g.NewButton("go printInt(x) (read x values off the channel)", func () { - debugWG.Add(1) - go printInt(2, "routine1") - debugWG.Add(1) - go printInt(2, "routine2") + g.NewButton("go printInt(x) (read x values off the channel)", func() { + debugWG.Add(1) + go printInt(2, "routine1") + debugWG.Add(1) + go printInt(2, "routine2") }) - g.NewButton("sendNumber(2) (chan <- 2, 4)", func () { + g.NewButton("sendNumber(2) (chan <- 2, 4)", func() { debugWG.Add(1) debugWG.Add(1) go sendNumber(2) go sendNumber(4) }) - g.NewButton("sendNumber(1) (chan <- 7)", func () { + g.NewButton("sendNumber(1) (chan <- 7)", func() { debugWG.Add(1) go sendNumber(7) }) - g.NewButton("send 4 numbers (chan <- int)", func () { + g.NewButton("send 4 numbers (chan <- int)", func() { log.Log(CHAN, "generateNumbers(4)") go generateNumbers(4) }) - g.NewButton("debugWG.Done()", func () { + g.NewButton("debugWG.Done()", func() { log.Log(CHAN, "ran debugWG.Done()") debugWG.Done() }) - g.NewButton("close chan", func () { + g.NewButton("close chan", func() { log.Log(CHAN, "close() on", debugNumberChan) close(debugNumberChan) }) - g.NewButton("print", func () { + g.NewButton("print", func() { log.Log(CHAN, "waitgroup counter is ?") }) return w @@ -92,9 +92,9 @@ func printInt(i int, name string) { tmp := 1 log.Log(CHAN, "START printInt", name, "read debugNumberChan()") for num := range debugNumberChan { - log.Log(CHAN, "printInt()",name, "read", num, "from channel") + log.Log(CHAN, "printInt()", name, "read", num, "from channel") debugWG.Done() - if (tmp == i) { + if tmp == i { return } tmp += 1 |
