// throttle sees if throttling needs take place, and if so, continuously sleeps (blocks)
// until throttling reasons are gone
throttle sees if throttling needs take place, and if so, continuously sleeps (blocks)
until throttling reasons are gone
// throttle sees if throttling needs take place and if so continuously sleeps ( blocks ) // until throttling reasons are gone
func (this *Throttler) throttle(onThrottled func()) {
	for {
		if shouldThrottle, _ := this.migrationContext.IsThrottled(); !shouldThrottle {
			return
		}
		if onThrottled != nil {
			onThrottled()
		}
		time.Sleep(250 * time.Millisecond)
	}
}
func ( this * Throttler ) throttle ( onThrottled func ( ) ) { for { if shouldThrottle , _ := this . migrationContext . IsThrottled ( ) ; ! shouldThrottle { return } if onThrottled != nil { onThrottled ( ) } time . Sleep ( 250 * time . Millisecond ) } }
throttle sees if throttling needs take place, and if so, continuously sleeps (blocks)
until throttling reasons are gone
throttle sees if throttling needs take place and if so continuously sleeps ( blocks ) until throttling reasons are gone
// IsThrottled() is non-blocking; the throttling decision making takes place asynchronously. // Therefore calling IsThrottled() is cheap