Forgot to close some chans
This commit is contained in:
parent
21b3c6b9e9
commit
63547f2d37
24
bandwidth.go
24
bandwidth.go
@ -73,6 +73,8 @@ outer:
|
|||||||
}
|
}
|
||||||
close(bw.AddRx)
|
close(bw.AddRx)
|
||||||
close(bw.AddTx)
|
close(bw.AddTx)
|
||||||
|
close(bw.Rx)
|
||||||
|
close(bw.Tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// datum stores both a piece of info, plus the time at which that info was
|
// datum stores both a piece of info, plus the time at which that info was
|
||||||
@ -116,6 +118,16 @@ func newStream(seconds []int) *stream {
|
|||||||
|
|
||||||
func (s *stream) add(v datum) {
|
func (s *stream) add(v datum) {
|
||||||
s.data.PushBack(v)
|
s.data.PushBack(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *stream) averages() []float64 {
|
||||||
|
var limit time.Time
|
||||||
|
total := 0.0
|
||||||
|
totals := []float64{}
|
||||||
|
|
||||||
|
if s.data.Back() == nil {
|
||||||
|
return totals
|
||||||
|
}
|
||||||
newest := s.data.Back().Value.(datum)
|
newest := s.data.Back().Value.(datum)
|
||||||
cutoff := newest.at.Add(s.max)
|
cutoff := newest.at.Add(s.max)
|
||||||
for e := s.data.Front(); e != nil; e = e.Next() {
|
for e := s.data.Front(); e != nil; e = e.Next() {
|
||||||
@ -126,19 +138,7 @@ func (s *stream) add(v datum) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (s *stream) averages() []float64 {
|
|
||||||
var limit time.Time
|
|
||||||
|
|
||||||
total := 0.0
|
|
||||||
|
|
||||||
totals := []float64{}
|
|
||||||
if s.data.Back() == nil {
|
|
||||||
return totals
|
|
||||||
}
|
|
||||||
|
|
||||||
newest := s.data.Back().Value.(datum)
|
|
||||||
e := s.data.Back()
|
e := s.data.Back()
|
||||||
|
|
||||||
for _, extent := range s.extents {
|
for _, extent := range s.extents {
|
||||||
|
Loading…
Reference in New Issue
Block a user