risinglight
risinglight copied to clipboard
storage: use object to pin and unpin version
https://github.com/risinglightdb/risinglight/blob/7b5bc7a1a258afd64a483990ca95f4c799482791/src/storage/secondary/version_manager.rs#L258-L263
Currently, users will need to manually call pin
and unpin
. If there are futures cancelled or somehow, it is possible that we fail to unpin by ourselves.
We should implement a struct called Version
, and implement Drop
for it. pin
will return a Arc<Version>
instead of some strange things. When a Version
gets dropped (which means that all reference of Arc<Version>
is now dropped), we can call unpin
in Drop
.
pub struct Version(u64, Arc<Snapshot>);
impl Drop for Version {
// ...
}
pub fn pin(&self) -> Arc<Version> { /* .. */ }
I'm not familiar with rust, May I try this issue? :)
Sure, thanks for that!