Golang Context 探究
{ c.mu.Unlock() return // 已经被其他协程取消 } c.err = err // 关闭 channel,通知其他协程 if c.done == nil { c.done = closedchan } else { close(c.done) } // 遍历它的所有子节点 for child := range c.children { // 递归地取消所有子节点 child.cancel(false, err) } // 将子节点置空 c.children = nil c.mu.Unlock() if removeFromParent { // 从父节点中移除自己 removeChild(c.Context, c) } } context.timerCtx timerCtx 基于...阅读全文