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

Create a HandleCache type #44

Open
Others opened this issue Aug 1, 2020 · 0 comments
Open

Create a HandleCache type #44

Others opened this issue Aug 1, 2020 · 0 comments
Labels
good first issue Good for newcomers T-enhancement New feature or request

Comments

@Others
Copy link
Owner

Others commented Aug 1, 2020

It'd be cool if on the hot path instead of writing:

for $BIG__LOOP {
    // do work
    let x = gc.get() // gets a handle every loop -- potentially expensive
    // operate on x

    // drop x/the handle
}

You could use a struct to cache the handles:

let cache = HandleCache::new();
for $BIG__LOOP {
    // do work
    let x = cache.get(gc) // only gets the handle once, then caches it
    // operate on x
}
// drop all the handles in the cache when it is dropped

We'd need to evaluate if this is ever potentially a footgun, but it would seem to provide more control over the whole collection process. (It also seems pretty straightforward to implement!)

Could be combined with #43 for a super fast hot path!!!

@Others Others added T-enhancement New feature or request good first issue Good for newcomers labels Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers T-enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant