package neo

import (
	
)

type ticker struct {
	time *Time
	ch   chan time.Time
	id   int
	dur  time.Duration
}

func ( *ticker) () <-chan time.Time {
	return .ch
}

func ( *ticker) () {
	.time.stop(.id)
}

func ( *ticker) ( time.Duration) {
	.time.reset(, .id, .do, &.dur)
}

// do is the ticker’s moment callback. It sends the now time to the underlying
// channel and plans a new moment for the next tick. Note that do runs under
// Time’s lock.
func ( *ticker) ( time.Time) {
	.ch <- 

	// It is safe to mutate ID without a lock since at most one moment
	// exists for the given ticker and moments run under the Time’s lock.
	.time.resetUnlocked(.dur, .id, ., nil)

	// Ticker used to create a new moment for each tick and that would close
	// the observe channel. Maintain backwards compatibility for users that
	// may rely on this behavior.
	.time.observeUnlocked()
}