github.com/relnod/pegomock@v2.0.1+incompatible/pegomock/util/time.go (about)

     1  package util
     2  
     3  import "time"
     4  
     5  // Ticker repeatedly calls cb with a delay in between calls. It stops doing This
     6  // When a element is sent to the done channel.
     7  func Ticker(cb func(), delay time.Duration, done chan bool) {
     8  	for {
     9  		select {
    10  		case <-done:
    11  			return
    12  
    13  		default:
    14  			cb()
    15  			time.Sleep(delay)
    16  		}
    17  	}
    18  }