Razeen`s Blog

Razeen`s Blog

Recent content on Razeen`s Blog

马上订阅 Razeen`s Blog RSS 更新: https://razeen.me/index.xml

Go学习笔记(九) 计时器的生命周期[译]

2020年8月15日 15:41

Illustration created for “A Journey With Go”, made from the original Go Gopher, created by Renee French.

全文基于GO 1.14

计时器在定时执行一些任务时很有用。Go内部依靠调度器来管理创建的计时器。而Go的调度程序是协作式的调度方式,这会让整个调度看起来比较复杂,因为goroutune必须自己停止(依赖channel阻塞或system call), 或者由调度器自己在某个调度点暂停。