diff options
| author | Paul Buetow (europa) <paul@buetow.org> | 2015-05-25 01:10:10 +0100 |
|---|---|---|
| committer | Paul Buetow (europa) <paul@buetow.org> | 2015-05-25 01:10:10 +0100 |
| commit | d38431533e517dfa3efc48d219701b25f77289ac (patch) | |
| tree | 6847b08ce6979ad9d2a465266164621643030f3e /gstat | |
| parent | 6e3ebb236e396c727564415d1f6b0fd1f2e72457 (diff) | |
move
Diffstat (limited to 'gstat')
| -rw-r--r-- | gstat/main.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gstat/main.go b/gstat/main.go new file mode 100644 index 0000000..6cef683 --- /dev/null +++ b/gstat/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "fmt" + "github.com/buetow/gstat/process" + "time" +) + +func gather(timer <-chan bool, processes chan<- process.Process) { + for { + switch <-timer { + case false: + { + break + } + case true: + { + process.Gather(processes) + } + } + } + close(processes) +} + +func receive(processes <-chan process.Process) { + for process := range processes { + process.Print() + } +} + +func main() { + timer := make(chan bool) + res := make(chan process.Process) + + go gather(timer, res) + go receive(res) + + for counter := 0; counter < 3; counter++ { + timer <- true + time.Sleep(time.Second) + fmt.Printf("Next... %d\n", counter) + } + timer <- false + + fmt.Println("Good bye") +} |
