Commit e4dc7f1e authored by Sameer Ajmani's avatar Sameer Ajmani

context: update documentation on cancelation and go vet check.

Also replace double spaces after periods with single spaces.

Change-Id: Iedaea47595c5ce64e7e8aa3a368f36d49061c555
Reviewed-on: https://go-review.googlesource.com/24431Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent 3c6ed76d
...@@ -6,18 +6,21 @@ ...@@ -6,18 +6,21 @@
// cancelation signals, and other request-scoped values across API boundaries // cancelation signals, and other request-scoped values across API boundaries
// and between processes. // and between processes.
// //
// Incoming requests to a server should create a Context, and outgoing calls to // Incoming requests to a server should create a Context, and outgoing
// servers should accept a Context. The chain of function calls between them // calls to servers should accept a Context. The chain of function
// must propagate the Context, optionally replacing it with a derived Context // calls between them must propagate the Context, optionally replacing
// created using WithCancel, WithDeadline, WithTimeout, or WithValue. These // it with a derived Context created using WithCancel, WithDeadline,
// Context values form a tree: when a Context is canceled, all Contexts derived // WithTimeout, or WithValue. When a Context is canceled, all
// from it are also canceled. // Contexts derived from it are also canceled.
// //
// The WithCancel, WithDeadline, and WithTimeout functions return a derived // The WithCancel, WithDeadline, and WithTimeout functions take a
// Context and a CancelFunc. Calling the CancelFunc cancels the new Context and // Context (the parent) and return a derived Context (the child) and a
// any Contexts derived from it, removes the Context from the parent's tree, and // CancelFunc. Calling the CancelFunc cancels the child and its
// stops any associated timers. Failing to call the CancelFunc leaks the // children, removes the parent's reference to the child, and stops
// associated resources until the parent Context is canceled or the timer fires. // any associated timers. Failing to call the CancelFunc leaks the
// child and its children until the parent is canceled or the timer
// fires. The go vet tool checks that CancelFuncs are used on all
// control-flow paths.
// //
// Programs that use Contexts should follow these rules to keep interfaces // Programs that use Contexts should follow these rules to keep interfaces
// consistent across packages and enable static analysis tools to check context // consistent across packages and enable static analysis tools to check context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment