[go-nuts] cancel method of timerCtx of context package

2021-05-12 Thread qinggeer Bao
In the cancel method of timerCtx type: func (c *timerCtx) cancel(removeFromParent bool, err error) { c.cancelCtx.cancel(false, err) if removeFromParent { // Remove this timerCtx from its parent cancelCtx's children. removeChild(c.cancelCtx.Context, c) } c.mu.Lock()

Re: [go-nuts] context package: why need run goroutine in propagateCancel function

2021-04-26 Thread qinggeer Bao
Thanks. I see. 在2021年4月27日星期二 UTC+8 上午5:50:09 写道: > On Mon, Apr 26, 2021 at 9:59 AM qinggeer Bao wrote: > > > > if parentCancelCtx return false, it means no cancellable ancestors > found, then why do we need run another goroutine to listen for parent's > cancel sig

[go-nuts] context package: why need run goroutine in propagateCancel function

2021-04-26 Thread qinggeer Bao
For learning purpose, I'm reading the source code of Golang standard package: context. Roughly understand the logics with one confusing point in the propagateCancel below: func propagateCancel(parent Context, child canceler) { done := parent.Done() if done == nil { return // pare