Initializing the ring buffer with no cells

This commit is contained in:
Diptanu Choudhury
2016-05-26 18:23:44 -07:00
parent 455c7591c5
commit 2571ea61bb

View File

@@ -461,8 +461,11 @@ func (r *TaskRunner) startTask() error {
// collectResourceUsageStats starts collecting resource usage stats of a Task
func (r *TaskRunner) collectResourceUsageStats() {
// start collecting the stats right away and then start collecting every
// collection interval
next := time.NewTimer(0)
defer next.Stop()
for {
next := time.NewTimer(r.config.StatsCollectionInterval)
select {
case <-next.C:
ru, err := r.handle.Stats()
@@ -474,7 +477,6 @@ func (r *TaskRunner) collectResourceUsageStats() {
r.resourceUsageLock.Unlock()
next.Reset(r.config.StatsCollectionInterval)
case <-r.handle.WaitCh():
next.Stop()
return
}
}