devirtualize database

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-05-28 06:59:50 +00:00
parent 7ad7badd60
commit de21f7442a
12 changed files with 497 additions and 744 deletions

View file

@ -1,16 +1,16 @@
use std::sync::Arc;
use super::KeyValueDatabaseEngine;
use crate::Engine;
pub struct Cork {
db: Arc<dyn KeyValueDatabaseEngine>,
db: Arc<Engine>,
flush: bool,
sync: bool,
}
impl Cork {
pub fn new(db: &Arc<dyn KeyValueDatabaseEngine>, flush: bool, sync: bool) -> Self {
db.cork().unwrap();
pub fn new(db: &Arc<Engine>, flush: bool, sync: bool) -> Self {
db.cork();
Self {
db: db.clone(),
flush,
@ -21,7 +21,7 @@ impl Cork {
impl Drop for Cork {
fn drop(&mut self) {
self.db.uncork().ok();
self.db.uncork();
if self.flush {
self.db.flush().ok();
}