diff options
| author | Paul Buetow (europa) <paul@buetow.org> | 2015-05-25 22:14:24 +0100 |
|---|---|---|
| committer | Paul Buetow (europa) <paul@buetow.org> | 2015-05-25 22:14:24 +0100 |
| commit | 6cf925c8072bddf54e5b43de21b74be7451de67d (patch) | |
| tree | 38824a7a2be77898d76500e0d187b3f0b8e82922 | |
| parent | c97f78aae969f337ba513c562f53246cd33cd4bc (diff) | |
refactor
| -rw-r--r-- | gstat/main.go | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gstat/main.go b/gstat/main.go index 9d02b44..5a6d83b 100644 --- a/gstat/main.go +++ b/gstat/main.go @@ -14,7 +14,7 @@ type twoProcesses struct { } type processMap map[string]twoProcesses -func gather(timer <-chan bool, d chan<- diskstats.Diskstats, p chan<- process.Process) { +func gather(timer <-chan bool, dChan chan<- diskstats.Diskstats, pChan chan<- process.Process) { for { switch <-timer { case false: @@ -23,26 +23,26 @@ func gather(timer <-chan bool, d chan<- diskstats.Diskstats, p chan<- process.Pr } case true: { - diskstats.Gather(d) - process.Gather(p) + diskstats.Gather(dChan) + process.Gather(pChan) } } } - close(d) - close(p) + close(dChan) + close(pChan) } -func receiveD(diskstats <-chan diskstats.Diskstats) { - for d := range diskstats { +func receiveD(dChan <-chan diskstats.Diskstats) { + for d := range dChan { //diskstats.Print() // Implemented later _ = d } } -func receiveP(processes <-chan process.Process) { +func receiveP(pChan <-chan process.Process) { lastP := make(processMap) - for p := range processes { + for p := range pChan { if val, ok := lastP[p.Id]; ok { if val.flag { val.second = p @@ -58,13 +58,13 @@ func receiveP(processes <-chan process.Process) { func main() { timer := make(chan bool) - diskstats := make(chan diskstats.Diskstats) - processes := make(chan process.Process) + dChan := make(chan diskstats.Diskstats) + pChan := make(chan process.Process) - go gather(timer, diskstats, processes) + go gather(timer, dChan, pChan) - go receiveD(diskstats) - go receiveP(processes) + go receiveD(dChan) + go receiveP(pChan) for counter := 0; counter < 3; counter++ { timer <- true |
