package backoff

import 

type Timer interface {
	Start(duration time.Duration)
	Stop()
	C() <-chan time.Time
}

// defaultTimer implements Timer interface using time.Timer
type defaultTimer struct {
	timer *time.Timer
}

// C returns the timers channel which receives the current time when the timer fires.
func ( *defaultTimer) () <-chan time.Time {
	return .timer.C
}

// Start starts the timer to fire after the given duration
func ( *defaultTimer) ( time.Duration) {
	if .timer == nil {
		.timer = time.NewTimer()
	} else {
		.timer.Reset()
	}
}

// Stop is called when the timer is not used anymore and resources may be freed.
func ( *defaultTimer) () {
	if .timer != nil {
		.timer.Stop()
	}
}