From e103e1c277da084bc2835d600aef4dfe14b66085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 13 Feb 2019 15:19:02 +0100 Subject: [PATCH] chore: Replace the crossbeam::ArcCell by arc-swap::ArcSwap --- Cargo.toml | 2 +- src/database/mod.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8a02b2657..0b4d6c092 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Kerollmops "] [dependencies] bincode = "1.0" byteorder = "1.2" -crossbeam = "0.6" +arc-swap = "0.3" elapsed = "0.1" fst = "0.3" hashbrown = { version = "0.1", features = ["serde"] } diff --git a/src/database/mod.rs b/src/database/mod.rs index 8097dd726..791634b2d 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -11,7 +11,7 @@ use std::ops::{Deref, DerefMut}; use rocksdb::rocksdb_options::{DBOptions, ColumnFamilyOptions}; use rocksdb::rocksdb::{Writable, Snapshot}; use rocksdb::{DB, MergeOperands}; -use crossbeam::atomic::ArcCell; +use arc_swap::ArcSwap; use lockfree::map::Map; use hashbrown::HashMap; use log::{info, error, warn}; @@ -141,7 +141,7 @@ struct DatabaseIndex { db: Arc, // This view is updated each time the DB ingests an update. - view: ArcCell>>, + view: ArcSwap>>, // The path of the mdb folder stored on disk. path: PathBuf, @@ -175,7 +175,7 @@ impl DatabaseIndex { let db = Arc::new(db); let snapshot = Snapshot::new(db.clone()); - let view = ArcCell::new(Arc::new(DatabaseView::new(snapshot)?)); + let view = ArcSwap::new(Arc::new(DatabaseView::new(snapshot)?)); Ok(DatabaseIndex { db: db, @@ -204,7 +204,7 @@ impl DatabaseIndex { let db = Arc::new(db); let snapshot = Snapshot::new(db.clone()); - let view = ArcCell::new(Arc::new(DatabaseView::new(snapshot)?)); + let view = ArcSwap::new(Arc::new(DatabaseView::new(snapshot)?)); Ok(DatabaseIndex { db: db, @@ -233,13 +233,13 @@ impl DatabaseIndex { let snapshot = Snapshot::new(self.db.clone()); let view = Arc::new(DatabaseView::new(snapshot)?); - self.view.set(view.clone()); + self.view.store(view.clone()); Ok(view) } fn view(&self) -> Arc>> { - self.view.get() + self.view.load() } }