diff --git a/Cargo.toml b/Cargo.toml index 762d5b54..89aff658 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ crossbeam = "0.8" dashmap = "6" hashlink = "0.9" indexmap = "2" -orx-concurrent-vec = "2" +append-only-vec = "0.1" tracing = "0.1" parking_lot = "0.12" rustc-hash = "2" diff --git a/src/views.rs b/src/views.rs index 5fd08c2f..b815ed52 100644 --- a/src/views.rs +++ b/src/views.rs @@ -1,12 +1,10 @@ +use crate::Database; +use append_only_vec::AppendOnlyVec; use std::{ any::{Any, TypeId}, sync::Arc, }; -use orx_concurrent_vec::ConcurrentVec; - -use crate::Database; - /// A `Views` struct is associated with some specific database type /// (a `DatabaseImpl` for some existential `U`). It contains functions /// to downcast from that type to `dyn DbView` for various traits `DbView`. @@ -26,7 +24,7 @@ use crate::Database; #[derive(Clone)] pub struct Views { source_type_id: TypeId, - view_casters: Arc>, + view_casters: Arc>, } /// A ViewCaster contains a trait object that can cast from the @@ -91,7 +89,7 @@ impl Views { let source_type_id = TypeId::of::(); Self { source_type_id, - view_casters: Default::default(), + view_casters: Arc::new(AppendOnlyVec::new()), } } diff --git a/src/zalsa.rs b/src/zalsa.rs index c91a02d0..dabd249b 100644 --- a/src/zalsa.rs +++ b/src/zalsa.rs @@ -1,11 +1,10 @@ +use append_only_vec::AppendOnlyVec; +use parking_lot::Mutex; +use rustc_hash::FxHashMap; use std::any::{Any, TypeId}; use std::marker::PhantomData; use std::thread::ThreadId; -use orx_concurrent_vec::ConcurrentVec; -use parking_lot::Mutex; -use rustc_hash::FxHashMap; - use crate::cycle::CycleRecoveryStrategy; use crate::ingredient::{Ingredient, Jar}; use crate::nonce::{Nonce, NonceGenerator}; @@ -102,10 +101,10 @@ pub struct Zalsa { /// Vector of ingredients. /// /// Immutable unless the mutex on `ingredients_map` is held. - ingredients_vec: ConcurrentVec>, + ingredients_vec: AppendOnlyVec>, /// Indices of ingredients that require reset when a new revision starts. - ingredients_requiring_reset: ConcurrentVec, + ingredients_requiring_reset: AppendOnlyVec, /// The runtime for this particular salsa database handle. /// Each handle gets its own runtime, but the runtimes have shared state between them. @@ -118,8 +117,8 @@ impl Zalsa { views_of: Views::new::(), nonce: NONCE.nonce(), jar_map: Default::default(), - ingredients_vec: Default::default(), - ingredients_requiring_reset: Default::default(), + ingredients_vec: AppendOnlyVec::new(), + ingredients_requiring_reset: AppendOnlyVec::new(), runtime: Runtime::default(), } } @@ -156,7 +155,7 @@ impl Zalsa { expected_index.as_usize(), actual_index, "ingredient `{:?}` was predicted to have index `{:?}` but actually has index `{:?}`", - self.ingredients_vec.get(actual_index).unwrap(), + self.ingredients_vec[actual_index], expected_index, actual_index, ); @@ -168,12 +167,12 @@ impl Zalsa { } pub(crate) fn lookup_ingredient(&self, index: IngredientIndex) -> &dyn Ingredient { - &**self.ingredients_vec.get(index.as_usize()).unwrap() + &**(&self.ingredients_vec[index.as_usize()]) } /// **NOT SEMVER STABLE** pub fn lookup_ingredient_mut(&mut self, index: IngredientIndex) -> &mut dyn Ingredient { - &mut **self.ingredients_vec.get_mut(index.as_usize()).unwrap() + &mut **(&mut self.ingredients_vec[index.as_usize()]) } /// **NOT SEMVER STABLE** @@ -204,10 +203,7 @@ impl Zalsa { let new_revision = self.runtime.new_revision(); for index in self.ingredients_requiring_reset.iter() { - self.ingredients_vec - .get_mut(index.as_usize()) - .unwrap() - .reset_for_new_revision(); + self.ingredients_vec[index.as_usize()].reset_for_new_revision(); } new_revision