mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 12:56:33 +00:00
Fix parallel_map::execute_cancellation test
This commit is contained in:
parent
c8d47cc01a
commit
87fdc13d4f
2 changed files with 3 additions and 6 deletions
|
@ -15,17 +15,18 @@ struct ParallelInput {
|
||||||
fn tracked_fn(db: &dyn salsa::Database, input: ParallelInput) -> Vec<u32> {
|
fn tracked_fn(db: &dyn salsa::Database, input: ParallelInput) -> Vec<u32> {
|
||||||
salsa::par_map(db, input.field(db), |_db, field| field + 1)
|
salsa::par_map(db, input.field(db), |_db, field| field + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::tracked]
|
#[salsa::tracked]
|
||||||
fn a1(db: &dyn KnobsDatabase, input: ParallelInput) -> Vec<u32> {
|
fn a1(db: &dyn KnobsDatabase, input: ParallelInput) -> Vec<u32> {
|
||||||
db.signal(1);
|
db.signal(1);
|
||||||
salsa::par_map(db, input.field(db), |db, field| {
|
salsa::par_map(db, input.field(db), |db, field| {
|
||||||
db.wait_for(2);
|
db.wait_for(2);
|
||||||
field + 1
|
field + dummy(db)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[salsa::tracked]
|
#[salsa::tracked]
|
||||||
fn dummy(_db: &dyn KnobsDatabase, _input: ParallelInput) -> ParallelInput {
|
fn dummy(_db: &dyn KnobsDatabase) -> u32 {
|
||||||
panic!("should never get here!")
|
panic!("should never get here!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,6 @@ pub(crate) struct Signal {
|
||||||
|
|
||||||
impl Signal {
|
impl Signal {
|
||||||
pub(crate) fn signal(&self, stage: usize) {
|
pub(crate) fn signal(&self, stage: usize) {
|
||||||
dbg!(format!("signal({})", stage));
|
|
||||||
|
|
||||||
// This check avoids acquiring the lock for things that will
|
// This check avoids acquiring the lock for things that will
|
||||||
// clearly be a no-op. Not *necessary* but helps to ensure we
|
// clearly be a no-op. Not *necessary* but helps to ensure we
|
||||||
// are more likely to encounter weird race conditions;
|
// are more likely to encounter weird race conditions;
|
||||||
|
@ -27,8 +25,6 @@ impl Signal {
|
||||||
/// Waits until the given condition is true; the fn is invoked
|
/// Waits until the given condition is true; the fn is invoked
|
||||||
/// with the current stage.
|
/// with the current stage.
|
||||||
pub(crate) fn wait_for(&self, stage: usize) {
|
pub(crate) fn wait_for(&self, stage: usize) {
|
||||||
dbg!(format!("wait_for({})", stage));
|
|
||||||
|
|
||||||
// As above, avoid lock if clearly a no-op.
|
// As above, avoid lock if clearly a no-op.
|
||||||
if stage > 0 {
|
if stage > 0 {
|
||||||
let mut v = self.value.lock();
|
let mut v = self.value.lock();
|
||||||
|
|
Loading…
Reference in a new issue