Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an async lazy class and lazy lifetimes #1861

Merged
merged 4 commits into from
Apr 20, 2020
Merged

Conversation

bwateratmsft
Copy link
Collaborator

@bwateratmsft bwateratmsft commented Apr 14, 2020

(Not for 1.1)

Adds an AsyncLazy class that is smart enough to not re-run the task if it's currently running. Also adds lifetimes to force Lazys to re-evaluate, if the caller so specifies.

One scenario where this would be useful is in places where we know we are going to query something several times in rapid succession--maybe docker info, as an example--and we expect no changes to occur in some time span (e.g. 1 second), but want to share the result across each of these queries to avoid re-running code unnecessarily.

src/utils/lazy.ts Outdated Show resolved Hide resolved
src/utils/lazy.ts Outdated Show resolved Hide resolved
src/utils/lazy.ts Outdated Show resolved Hide resolved
src/utils/lazy.ts Show resolved Hide resolved
src/utils/lazy.ts Show resolved Hide resolved
src/utils/lazy.ts Show resolved Hide resolved
src/utils/lazy.ts Outdated Show resolved Hide resolved
src/utils/lazy.ts Show resolved Hide resolved
src/utils/lazy.ts Show resolved Hide resolved
test/utils/lazy.test.ts Show resolved Hide resolved
@bwateratmsft bwateratmsft merged commit d0b342d into master Apr 20, 2020
@bwateratmsft bwateratmsft deleted the bmw/asynclazy branch April 20, 2020 19:22
Dmarch28 pushed a commit to Dmarch28/vscode-docker that referenced this pull request Mar 4, 2021
* Add an async lazy class and lazy lifetimes

* Add unit tests
@microsoft microsoft locked and limited conversation to collaborators Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants