package backoff

import 

/*
WithMaxRetries creates a wrapper around another BackOff, which will
return Stop if NextBackOff() has been called too many times since
the last time Reset() was called

Note: Implementation is not thread-safe.
*/
func ( BackOff,  uint64) BackOff {
	return &backOffTries{delegate: , maxTries: }
}

type backOffTries struct {
	delegate BackOff
	maxTries uint64
	numTries uint64
}

func ( *backOffTries) () time.Duration {
	if .maxTries == 0 {
		return Stop
	}
	if .maxTries > 0 {
		if .maxTries <= .numTries {
			return Stop
		}
		.numTries++
	}
	return .delegate.NextBackOff()
}

func ( *backOffTries) () {
	.numTries = 0
	.delegate.Reset()
}