@cryptotaxi247 / kubo / commits / a6a645269

fix(blockservice/worker) replace time.Tick with a timer we can stop

Brian Tiger Chow committed Jan 20, 2015 at 23:31 UTC a6a6452692f8ff3028ebe3181ea7102a17a6e929
1 file changed +3 -1
blockservice/worker/worker.go
+3 -1
@@ -84,6 +84,8 @@ func (w *Worker) start(c Config) {
84 defer close(workerChan)
85
86 var workQueue BlockList
87 + debugInfo := time.NewTicker(5 * time.Second)
88 + defer debugInfo.Stop()
89 for {
90
91 // take advantage of the fact that sending on nil channel always
@@ -99,7 +101,7 @@ func (w *Worker) start(c Config) {
101 // if worker is ready and there's a block to process, send the
102 // block
103 case sendToWorker <- nextBlock:
102 - case <-time.Tick(5 * time.Second):
104 + case <-debugInfo.C:
105 if workQueue.Len() > 0 {
106 log.Debugf("%d blocks in blockservice provide queue...", workQueue.Len())
107 }