context: Adds module context based on Golang's context#9563
Merged
spytheman merged 60 commits intovlang:masterfrom Apr 12, 2021
ulises-jeremias:master
Merged
context: Adds module context based on Golang's context#9563spytheman merged 60 commits intovlang:masterfrom ulises-jeremias:master
spytheman merged 60 commits intovlang:masterfrom
ulises-jeremias:master
Conversation
* master: parser: filter out vet space indent errors inside StringInterLiterals (#9695) fmt: remove parenthesis around single ident (#9696) vdoc: fix output folder creation (#9699) docs: remove obsolete references to byteptr/charptr, use &byte/&char instead tools: implement progres bar for `v check-md .` docs: fix some mixed indentation, found by `v check-md .` tools: make `v check-md` more strict about unformatted code samples in `failcompile` sections. docs: document dump(expr) os: handle fread errors (#9687) tests: fix -skip-unused test on macos log: unify output order between cli and file (#9693) v.markused: mark all `pub` functions on `-shared -skip-unused` encoding.utf8: fix len and ulen and optimize raw_index (#9682)
Contributor
|
@mcastorina might be of interest to you 😉. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
This module defines the Context type, which carries deadlines, cancellation signals,
and other request-scoped values across API boundaries and between processes.
Incoming requests to a server should create a Context, and outgoing calls to servers
should accept a Context. The chain of function calls between them must propagate the
Context, optionally replacing it with a derived Context created using with_cancel,
with_deadline, with_timeout, or with_value. When a Context is canceled, all Contexts
derived from it are also canceled.
The with_cancel, with_deadline, and with_timeout functions take a Context (the parent)
and return a derived Context (the child) and a CancelFunc. Calling the CancelFunc
cancels the child and its children, removes the parent's reference to the child,
and stops any associated timers. Failing to call the CancelFunc leaks the child
and its children until the parent is canceled or the timer fires.
Programs that use Contexts should follow these rules to keep interfaces consistent
across different modules.
Do not store Contexts inside a struct type; instead, pass a Context explicitly
to each function that needs it. The Context should be the first parameter,
typically named ctx, just to make it more consistent.
Examples
In this section you can see some usage examples for this module
Context With Cancellation
Context With Deadline
Context With Timeout
Context With Value