Source File
ticker.go
Belonging Package
github.com/gotd/neo
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()
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |