On Mon, Apr 26, 2021 at 9:59 AM qinggeer Bao <baoq...@gmail.com> 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 
> signals? How it can happen in what kind of cases?

See the documentation of parentCancelCtx: "If not, the *cancelCtx has
been wrapped in a custom implementation providing a different done
channel, in which case we should not bypass it."  In other words,
people can and do provide their own custom implementations of the
context.Context interface.  For those implementations, parentCancelCtx
will return nil, but that doesn't mean that the custom implementation
can't be cancelled.  propagateCancel has to handle that case
correctly.  See also XTestWithCancel and
XTestWithCancelCanceledParent.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVK_nyJiiVw5QLcGeO5vimcN7BZ58Kf2OHK_cXVMvP8nA%40mail.gmail.com.

Reply via email to