start restoring parallel tests

This commit is contained in:
Niko Matsakis 2024-07-24 09:46:19 +00:00
parent 21af3a2009
commit 82d37de105
3 changed files with 12 additions and 13 deletions

View file

@ -1,7 +1,5 @@
#[cfg(disabled)]
mod setup;
#[cfg(disabled)]
mod parallel_cycle_all_recover;
#[cfg(disabled)]
mod parallel_cycle_mid_recover;
@ -9,5 +7,4 @@ mod parallel_cycle_mid_recover;
mod parallel_cycle_none_recover;
#[cfg(disabled)]
mod parallel_cycle_one_recover;
#[cfg(disabled)]
mod signal;

View file

@ -2,6 +2,8 @@
//! See `../cycles.rs` for a complete listing of cycle tests,
//! both intra and cross thread.
use salsa::Handle;
use crate::setup::Database;
use crate::setup::Knobs;
@ -90,18 +92,18 @@ fn recover_b2(db: &dyn Db, _cycle: &salsa::Cycle, key: MyInput) -> i32 {
#[test]
fn execute() {
let db = Database::default();
db.knobs().signal_on_will_block.set(3);
let db = Handle::new(Database::default());
db.knobs().signal_on_will_block.store(3);
let input = MyInput::new(&db, 1);
let input = MyInput::new(&*db, 1);
let thread_a = std::thread::spawn({
let db = db.snapshot();
let db = db.clone();
move || a1(&*db, input)
});
let thread_b = std::thread::spawn({
let db = db.snapshot();
let db = db.clone();
move || b1(&*db, input)
});

View file

@ -1,4 +1,4 @@
use std::{cell::Cell, sync::Arc};
use crossbeam::atomic::AtomicCell;
use crate::signal::Signal;
@ -15,14 +15,14 @@ pub(crate) trait Knobs {
/// Various "knobs" that can be used to customize how the queries
/// behave on one specific thread. Note that this state is
/// intentionally thread-local (apart from `signal`).
#[derive(Clone, Default)]
#[derive(Default)]
pub(crate) struct KnobsStruct {
/// A kind of flexible barrier used to coordinate execution across
/// threads to ensure we reach various weird states.
pub(crate) signal: Arc<Signal>,
pub(crate) signal: Signal,
/// When this database is about to block, send a signal.
pub(crate) signal_on_will_block: Cell<usize>,
pub(crate) signal_on_will_block: AtomicCell<usize>,
}
#[salsa::db]
@ -36,7 +36,7 @@ pub(crate) struct Database {
impl salsa::Database for Database {
fn salsa_event(&self, event: salsa::Event) {
if let salsa::EventKind::WillBlockOn { .. } = event.kind {
self.signal(self.knobs().signal_on_will_block.get());
self.signal(self.knobs().signal_on_will_block.load());
}
}
}