shredder icon indicating copy to clipboard operation
shredder copied to clipboard

Create a way to prevent collection happening

Open Others opened this issue 4 years ago • 4 comments

It'd be cool if there was a guard you could hold to prevent collection, something like:

fn prevent_collection() -> PreventCollectionGuard {...}

struct PreventCollectionGuard {...}

This may be useful for preventing collection on the hot path

Others avatar Aug 01 '20 06:08 Others

prevent collection should optionally block if there is a collection happening

Others avatar Aug 06 '20 21:08 Others

This is something I'd be interested in looking at when I finish up #33.

alekratz avatar Aug 10 '20 19:08 alekratz

Cool! I think we want prevent_collection to block until there is no collection going on. And when the handle drops, we want to make sure the collector has a chance to run

Others avatar Aug 10 '20 19:08 Others

@alekratz

Was thinking about this a bit more. Realized a few things:

  1. If Collector::gc_lock becomes a RWLock, that might be a start of the implementation
  2. If we implement this, we probably need a try_collect top level method, as there would now be a few ways of blocking collection
  3. PreventCollectionGuard might be useful for the deref work in the future, because it provides a guarantee that no one is concurrently scanning this data

Others avatar Aug 23 '20 00:08 Others