我正在阅读包的代码,time然后我想知道它是如何func After(d Duration) <-chan Time工作的.
我发现代码如下:
func After(d Duration) <-chan Time {
return NewTimer(d).C
}
func NewTimer(d Duration) *Timer {
c := make(chan Time, 1)
t := &Timer{
C: c,
r: runtimeTimer{
when: nano() + int64(d),
f: sendTime,
arg: c,
},
}
startTimer(&t.r)
return t
}
Run Code Online (Sandbox Code Playgroud)
所以我找到了startTimer- 函数startTimer没有函数体这么奇怪.
func startTimer(*runtimeTimer)
Run Code Online (Sandbox Code Playgroud)
我想知道:
startTimer 谢谢!