mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-08-09 13:28:19 +00:00
Simplify Event construction
This commit is contained in:
parent
638a094168
commit
266f620140
8 changed files with 27 additions and 34 deletions
|
@ -17,6 +17,15 @@ pub struct Event {
|
||||||
pub kind: EventKind,
|
pub kind: EventKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Event {
|
||||||
|
pub fn new(kind: EventKind) -> Self {
|
||||||
|
Self {
|
||||||
|
thread_id: std::thread::current().id(),
|
||||||
|
kind,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An enum identifying the various kinds of events that can occur.
|
/// An enum identifying the various kinds of events that can occur.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum EventKind {
|
pub enum EventKind {
|
||||||
|
|
|
@ -45,12 +45,11 @@ where
|
||||||
fn report_stale_output(db: &C::DbView, key: DatabaseKeyIndex, output: OutputDependencyIndex) {
|
fn report_stale_output(db: &C::DbView, key: DatabaseKeyIndex, output: OutputDependencyIndex) {
|
||||||
let db = db.as_dyn_database();
|
let db = db.as_dyn_database();
|
||||||
|
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| {
|
||||||
thread_id: std::thread::current().id(),
|
Event::new(EventKind::WillDiscardStaleOutput {
|
||||||
kind: EventKind::WillDiscardStaleOutput {
|
|
||||||
execute_key: key,
|
execute_key: key,
|
||||||
output_key: output,
|
output_key: output,
|
||||||
},
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
output.remove_stale_output(db, key);
|
output.remove_stale_output(db, key);
|
||||||
|
|
|
@ -31,11 +31,10 @@ where
|
||||||
|
|
||||||
tracing::info!("{:?}: executing query", database_key_index);
|
tracing::info!("{:?}: executing query", database_key_index);
|
||||||
|
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| {
|
||||||
thread_id: std::thread::current().id(),
|
Event::new(EventKind::WillExecute {
|
||||||
kind: EventKind::WillExecute {
|
|
||||||
database_key: database_key_index,
|
database_key: database_key_index,
|
||||||
},
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
// If we already executed this query once, then use the tracked-struct ids from the
|
// If we already executed this query once, then use the tracked-struct ids from the
|
||||||
|
|
|
@ -144,11 +144,10 @@ impl<V> Memo<V> {
|
||||||
revision_now: Revision,
|
revision_now: Revision,
|
||||||
database_key_index: DatabaseKeyIndex,
|
database_key_index: DatabaseKeyIndex,
|
||||||
) {
|
) {
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| {
|
||||||
thread_id: std::thread::current().id(),
|
Event::new(EventKind::DidValidateMemoizedValue {
|
||||||
kind: EventKind::DidValidateMemoizedValue {
|
|
||||||
database_key: database_key_index,
|
database_key: database_key_index,
|
||||||
},
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
self.verified_at.store(revision_now);
|
self.verified_at.store(revision_now);
|
||||||
|
|
|
@ -191,12 +191,11 @@ impl Runtime {
|
||||||
assert!(!dg.depends_on(other_id, thread_id));
|
assert!(!dg.depends_on(other_id, thread_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| {
|
||||||
thread_id,
|
Event::new(EventKind::WillBlockOn {
|
||||||
kind: EventKind::WillBlockOn {
|
|
||||||
other_thread_id: other_id,
|
other_thread_id: other_id,
|
||||||
database_key,
|
database_key,
|
||||||
},
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let result = local_state.with_query_stack(|stack| {
|
let result = local_state.with_query_stack(|stack| {
|
||||||
|
|
|
@ -69,10 +69,7 @@ impl<Db: Database> Storage<Db> {
|
||||||
fn cancel_others(&self, db: &Db) {
|
fn cancel_others(&self, db: &Db) {
|
||||||
self.zalsa_impl.set_cancellation_flag();
|
self.zalsa_impl.set_cancellation_flag();
|
||||||
|
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| Event::new(EventKind::DidSetCancellationFlag));
|
||||||
thread_id: std::thread::current().id(),
|
|
||||||
kind: EventKind::DidSetCancellationFlag,
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut clones = self.coordinate.clones.lock();
|
let mut clones = self.coordinate.clones.lock();
|
||||||
while *clones != 1 {
|
while *clones != 1 {
|
||||||
|
|
|
@ -469,11 +469,10 @@ where
|
||||||
/// unspecified results (but not UB). See [`InternedIngredient::delete_index`] for more
|
/// unspecified results (but not UB). See [`InternedIngredient::delete_index`] for more
|
||||||
/// discussion and important considerations.
|
/// discussion and important considerations.
|
||||||
pub(crate) fn delete_entity(&self, db: &dyn crate::Database, id: Id) {
|
pub(crate) fn delete_entity(&self, db: &dyn crate::Database, id: Id) {
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| {
|
||||||
thread_id: std::thread::current().id(),
|
Event::new(crate::EventKind::DidDiscard {
|
||||||
kind: crate::EventKind::DidDiscard {
|
|
||||||
key: self.database_key_index(id),
|
key: self.database_key_index(id),
|
||||||
},
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let zalsa = db.zalsa();
|
let zalsa = db.zalsa();
|
||||||
|
@ -514,10 +513,7 @@ where
|
||||||
key_index: id,
|
key_index: id,
|
||||||
};
|
};
|
||||||
|
|
||||||
db.salsa_event(&|| Event {
|
db.salsa_event(&|| Event::new(EventKind::DidDiscard { key: executor }));
|
||||||
thread_id: std::thread::current().id(),
|
|
||||||
kind: EventKind::DidDiscard { key: executor },
|
|
||||||
});
|
|
||||||
|
|
||||||
for stale_output in memo.origin().outputs() {
|
for stale_output in memo.origin().outputs() {
|
||||||
stale_output.remove_stale_output(db, executor);
|
stale_output.remove_stale_output(db, executor);
|
||||||
|
|
|
@ -288,12 +288,7 @@ impl ZalsaLocal {
|
||||||
/// `salsa_event` is emitted when this method is called, so that should be
|
/// `salsa_event` is emitted when this method is called, so that should be
|
||||||
/// used instead.
|
/// used instead.
|
||||||
pub(crate) fn unwind_if_revision_cancelled(&self, db: &dyn Database) {
|
pub(crate) fn unwind_if_revision_cancelled(&self, db: &dyn Database) {
|
||||||
let thread_id = std::thread::current().id();
|
db.salsa_event(&|| Event::new(EventKind::WillCheckCancellation));
|
||||||
db.salsa_event(&|| Event {
|
|
||||||
thread_id,
|
|
||||||
|
|
||||||
kind: EventKind::WillCheckCancellation,
|
|
||||||
});
|
|
||||||
let zalsa = db.zalsa();
|
let zalsa = db.zalsa();
|
||||||
if zalsa.load_cancellation_flag() {
|
if zalsa.load_cancellation_flag() {
|
||||||
self.unwind_cancelled(zalsa.current_revision());
|
self.unwind_cancelled(zalsa.current_revision());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue