Ejemplo n.º 1
0
// Start spins up the scanning loop. Call Stop() to exit the loop.
func (rs *rangeScanner) Start(clock *hlc.Clock, stopper *util.Stopper) {
	stopper.Add(1)
	for _, queue := range rs.queues {
		queue.Start(clock, stopper)
	}
	go rs.scanLoop(clock, stopper)
}
Ejemplo n.º 2
0
func (tq *testQueue) Start(clock *hlc.Clock, stopper *util.Stopper) {
	stopper.Add(1)
	go func() {
		for {
			select {
			case <-time.After(1 * time.Millisecond):
				tq.Lock()
				if len(tq.ranges) > 0 {
					tq.ranges = tq.ranges[1:]
					tq.processed++
				}
				tq.Unlock()
			case <-stopper.ShouldStop():
				tq.Lock()
				tq.done = true
				tq.Unlock()
				stopper.SetStopped()
				return
			}
		}
	}()
}