// timerFunc is the timer goroutine that polls the timer for events.
// It contends for TTL's public interface mutex.
timerFunc is the timer goroutine that polls the timer for events.
It contends for TTL's public interface mutex.
// timerFunc is the timer goroutine that polls the timer for events . // It contends for TTL ' s public interface mutex .
func (ttl *TTL) timerFunc() {
	ttl.mu.Lock()
	ttl.running = true
	ttl.mu.Unlock()
	var tick time.Time
	for {
		select {
		case <-ttl.resetchan:
			break
		case tick = <-ttl.timer.C:
			break
		}
		ttl.mu.Lock()
		if tick.Before(ttl.nexttick) {
			ttl.mu.Unlock()
			continue
		}
		ttl.nexttick = tick
		ttl.timer.Stop()
		ttl.trim()
		if ttl.head == nil {
			ttl.running = false
			ttl.mu.Unlock()
			break
		}
		ttl.nexttick = ttl.head.timeoutAt
		ttl.timer.Reset(time.Until(ttl.head.timeoutAt))
		ttl.mu.Unlock()
	}
}
func ( ttl * TTL ) timerFunc ( ) { ttl . mu . Lock ( ) ttl . running = true ttl . mu . Unlock ( ) var tick time . Time for { select { case <- ttl . resetchan : break case tick = <- ttl . timer . C : break } ttl . mu . Lock ( ) if tick . Before ( ttl . nexttick ) { ttl . mu . Unlock ( ) continue } ttl . nexttick = tick ttl . timer . Stop ( ) ttl . trim ( ) if ttl . head == nil { ttl . running = false ttl . mu . Unlock ( ) break } ttl . nexttick = ttl . head . timeoutAt ttl . timer . Reset ( time . Until ( ttl . head . timeoutAt ) ) ttl . mu . Unlock ( ) } }
timerFunc is the timer goroutine that polls the timer for events.
timerFunc is the timer goroutine that polls the timer for events .
// Ignore delayed ticks of reset timer. // Channel needs not be exhausted, // fires at least once even when empty. // Exit thread if queue is empty. // Otherwise reset timer and note fire time.