Skip to content

Create a HandleCache type #44

Description

@Others

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!!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions