Others / shredder

Garbage collected smart pointers for Rust
MIT License
266 stars 9 forks source link

Create a way to prevent collection happening #43

Open Others opened 4 years ago

Others commented 4 years ago

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 commented 4 years ago

prevent collection should optionally block if there is a collection happening

alekratz commented 4 years ago

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

Others commented 4 years ago

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 commented 4 years ago

@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