shredder
shredder copied to clipboard
Create a way to prevent collection happening
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
prevent collection should optionally block if there is a collection happening
This is something I'd be interested in looking at when I finish up #33.
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
@alekratz
Was thinking about this a bit more. Realized a few things:
- If
Collector::gc_lock
becomes a RWLock, that might be a start of the implementation - If we implement this, we probably need a
try_collect
top level method, as there would now be a few ways of blocking collection -
PreventCollectionGuard
might be useful for thederef
work in the future, because it provides a guarantee that no one is concurrently scanning this data