summaryrefslogtreecommitdiff
path: root/gstat
diff options
context:
space:
mode:
authorPaul Buetow (europa) <paul@buetow.org>2015-05-25 21:57:13 +0100
committerPaul Buetow (europa) <paul@buetow.org>2015-05-25 21:57:13 +0100
commitb41d48ef0817025251ce080578168fd85cab15f9 (patch)
tree6c9f11e599d4c1f02274efe16f6bdc378ad20ae5 /gstat
parent10074fefc76404a1be7bddcc2b9d18bc0ee44056 (diff)
store prev results into a process map
Diffstat (limited to 'gstat')
-rw-r--r--gstat/main.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/gstat/main.go b/gstat/main.go
index 254edeb..9aefa60 100644
--- a/gstat/main.go
+++ b/gstat/main.go
@@ -7,6 +7,10 @@ import (
"time"
)
+type processMap map[string]process.Process
+
+var lastP processMap
+
func gather(timer <-chan bool, d chan<- diskstats.Diskstats, p chan<- process.Process) {
for {
switch <-timer {
@@ -32,7 +36,9 @@ func receive1(diskstats <-chan diskstats.Diskstats) {
}
func receive2(processes <-chan process.Process) {
+ lastP = make(processMap)
for process := range processes {
+ lastP[process.Id] = process
process.Print()
}
}
@@ -48,7 +54,7 @@ func main() {
for counter := 0; counter < 3; counter++ {
timer <- true
- time.Sleep(time.Second)
+ time.Sleep(time.Second * 2)
fmt.Printf("Next... %d\n", counter)
}