Skip to content

Commit

Permalink
Replace orx-concurrent-vec with boxcar
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Aug 5, 2024
1 parent 7bdf51c commit 16973c8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ description = "A generic framework for on-demand, incrementalized computation (e
[dependencies]
arc-swap = "1"
boomphf = "0.6"
boxcar = "0.2"
crossbeam = "0.8"
dashmap = "6"
hashlink = "0.9"
indexmap = "2"
orx-concurrent-vec = "2"
tracing = "0.1"
parking_lot = "0.12"
rustc-hash = "2"
Expand Down
7 changes: 3 additions & 4 deletions src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{
sync::Arc,
};

use orx_concurrent_vec::ConcurrentVec;

use crate::Database;

Expand All @@ -26,7 +25,7 @@ use crate::Database;
#[derive(Clone)]
pub struct Views {
source_type_id: TypeId,
view_casters: Arc<ConcurrentVec<ViewCaster>>,
view_casters: Arc<boxcar::Vec<ViewCaster>>,
}

/// A ViewCaster contains a trait object that can cast from the
Expand Down Expand Up @@ -104,7 +103,7 @@ impl Views {
if self
.view_casters
.iter()
.any(|u| u.target_type_id == target_type_id)
.any(|(_, u)| u.target_type_id == target_type_id)
{
return;
}
Expand Down Expand Up @@ -140,7 +139,7 @@ impl Views {
assert_eq!(self.source_type_id, db_type_id, "database type mismatch");

let view_type_id = TypeId::of::<DbView>();
for caster in self.view_casters.iter() {
for (_, caster) in self.view_casters.iter() {
if caster.target_type_id == view_type_id {
// SAFETY: We have some function that takes a thin reference to the underlying
// database type `X` and returns a (potentially wide) reference to `View`.
Expand Down
9 changes: 4 additions & 5 deletions src/zalsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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;

Expand Down Expand Up @@ -102,10 +101,10 @@ pub struct Zalsa {
/// Vector of ingredients.
///
/// Immutable unless the mutex on `ingredients_map` is held.
ingredients_vec: ConcurrentVec<Box<dyn Ingredient>>,
ingredients_vec: boxcar::Vec<Box<dyn Ingredient>>,

/// Indices of ingredients that require reset when a new revision starts.
ingredients_requiring_reset: ConcurrentVec<IngredientIndex>,
ingredients_requiring_reset: boxcar::Vec<IngredientIndex>,

/// The runtime for this particular salsa database handle.
/// Each handle gets its own runtime, but the runtimes have shared state between them.
Expand Down Expand Up @@ -140,7 +139,7 @@ impl Zalsa {
*jar_map
.entry(jar_type_id)
.or_insert_with(|| {
let index = IngredientIndex::from(self.ingredients_vec.len());
let index = IngredientIndex::from(self.ingredients_vec.count());
let ingredients = jar.create_ingredients(index);
for ingredient in ingredients {
let expected_index = ingredient.ingredient_index();
Expand Down Expand Up @@ -203,7 +202,7 @@ impl Zalsa {
pub(crate) fn new_revision(&mut self) -> Revision {
let new_revision = self.runtime.new_revision();

for index in self.ingredients_requiring_reset.iter() {
for (_, index) in self.ingredients_requiring_reset.iter() {
self.ingredients_vec
.get_mut(index.as_usize())
.unwrap()
Expand Down

0 comments on commit 16973c8

Please sign in to comment.