Source File
clock.go
Belonging Package
github.com/libp2p/go-libp2p/p2p/net/swarm
package swarmimport// InstantTimer is a timer that triggers at some instant rather than some durationtype InstantTimer interface {Reset(d time.Time) boolStop() boolCh() <-chan time.Time}// Clock is a clock that can create timers that trigger at some// instant rather than some durationtype Clock interface {Now() time.TimeSince(t time.Time) time.DurationInstantTimer(when time.Time) InstantTimer}type RealTimer struct{ t *time.Timer }var _ InstantTimer = (*RealTimer)(nil)func ( RealTimer) () <-chan time.Time {return .t.C}func ( RealTimer) ( time.Time) bool {return .t.Reset(time.Until())}func ( RealTimer) () bool {return .t.Stop()}type RealClock struct{}var _ Clock = RealClock{}func (RealClock) () time.Time {return time.Now()}func (RealClock) ( time.Time) time.Duration {return time.Since()}func (RealClock) ( time.Time) InstantTimer {:= time.NewTimer(time.Until())return &RealTimer{}}
![]() |
The pages are generated with Golds v0.8.2. (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |