]> Cypherpunks.ru repositories - gostls13.git/commit
context: add AfterFunc
authorDamien Neil <dneil@google.com>
Wed, 5 Apr 2023 23:06:36 +0000 (16:06 -0700)
committerDamien Neil <dneil@google.com>
Wed, 19 Apr 2023 19:13:01 +0000 (19:13 +0000)
commit54d429999c00f277c80b5698fb78c7b71f91aad9
tree41aa26b0fde50281270f80f5e5fcf934e569d7b5
parent9d53d7aa02a8e5fca52fb638116592b7f0b04823
context: add AfterFunc

Add an AfterFunc function, which registers a function to run after
a context has been canceled.

Add support for contexts that implement an AfterFunc method, which
can be used to avoid the need to start a new goroutine watching
the Done channel when propagating cancellation signals.

Fixes #57928

Change-Id: If0b2cdcc4332961276a1ff57311338e74916259c
Reviewed-on: https://go-review.googlesource.com/c/go/+/482695
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
api/next/57928.txt [new file with mode: 0644]
src/context/afterfunc_test.go [new file with mode: 0644]
src/context/context.go
src/context/context_test.go
src/context/example_test.go
src/context/x_test.go