深入理解Golang之context
:= &timerCtx{ cancelCtx: newCancelCtx(parent), deadline: d, } // 建立新建context与可取消context祖先节点的取消关联关系 propagateCancel(parent, c) dur := time.Until(d) if dur <= 0 { c.cancel(true, DeadlineExceeded) // deadline has already passed return c, func() { c.cancel(false, Canceled) } } c.mu.Lock() defer c.mu.Unlock() if c.err == nil { c.timer = time.AfterFunc(dur, func...阅读全文