mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 04:44:29 +00:00
Merge pull request #648 from Veykril/veykril/push-wltsrnxssltn
Simplify Event construction
This commit is contained in:
commit
28d95f237b
8 changed files with 27 additions and 34 deletions
|
@ -17,6 +17,15 @@ pub struct Event {
|
|||
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.
|
||||
#[derive(Debug)]
|
||||
pub enum EventKind {
|
||||
|
|
|
@ -45,12 +45,11 @@ where
|
|||
fn report_stale_output(db: &C::DbView, key: DatabaseKeyIndex, output: OutputDependencyIndex) {
|
||||
let db = db.as_dyn_database();
|
||||
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id: std::thread::current().id(),
|
||||
kind: EventKind::WillDiscardStaleOutput {
|
||||
db.salsa_event(&|| {
|
||||
Event::new(EventKind::WillDiscardStaleOutput {
|
||||
execute_key: key,
|
||||
output_key: output,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
output.remove_stale_output(db, key);
|
||||
|
|
|
@ -31,11 +31,10 @@ where
|
|||
|
||||
tracing::info!("{:?}: executing query", database_key_index);
|
||||
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id: std::thread::current().id(),
|
||||
kind: EventKind::WillExecute {
|
||||
db.salsa_event(&|| {
|
||||
Event::new(EventKind::WillExecute {
|
||||
database_key: database_key_index,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
// 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,
|
||||
database_key_index: DatabaseKeyIndex,
|
||||
) {
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id: std::thread::current().id(),
|
||||
kind: EventKind::DidValidateMemoizedValue {
|
||||
db.salsa_event(&|| {
|
||||
Event::new(EventKind::DidValidateMemoizedValue {
|
||||
database_key: database_key_index,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
self.verified_at.store(revision_now);
|
||||
|
|
|
@ -191,12 +191,11 @@ impl Runtime {
|
|||
assert!(!dg.depends_on(other_id, thread_id));
|
||||
}
|
||||
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id,
|
||||
kind: EventKind::WillBlockOn {
|
||||
db.salsa_event(&|| {
|
||||
Event::new(EventKind::WillBlockOn {
|
||||
other_thread_id: other_id,
|
||||
database_key,
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
let result = local_state.with_query_stack(|stack| {
|
||||
|
|
|
@ -69,10 +69,7 @@ impl<Db: Database> Storage<Db> {
|
|||
fn cancel_others(&self, db: &Db) {
|
||||
self.zalsa_impl.set_cancellation_flag();
|
||||
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id: std::thread::current().id(),
|
||||
kind: EventKind::DidSetCancellationFlag,
|
||||
});
|
||||
db.salsa_event(&|| Event::new(EventKind::DidSetCancellationFlag));
|
||||
|
||||
let mut clones = self.coordinate.clones.lock();
|
||||
while *clones != 1 {
|
||||
|
|
|
@ -469,11 +469,10 @@ where
|
|||
/// unspecified results (but not UB). See [`InternedIngredient::delete_index`] for more
|
||||
/// discussion and important considerations.
|
||||
pub(crate) fn delete_entity(&self, db: &dyn crate::Database, id: Id) {
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id: std::thread::current().id(),
|
||||
kind: crate::EventKind::DidDiscard {
|
||||
db.salsa_event(&|| {
|
||||
Event::new(crate::EventKind::DidDiscard {
|
||||
key: self.database_key_index(id),
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
let zalsa = db.zalsa();
|
||||
|
@ -514,10 +513,7 @@ where
|
|||
key_index: id,
|
||||
};
|
||||
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id: std::thread::current().id(),
|
||||
kind: EventKind::DidDiscard { key: executor },
|
||||
});
|
||||
db.salsa_event(&|| Event::new(EventKind::DidDiscard { key: executor }));
|
||||
|
||||
for stale_output in memo.origin().outputs() {
|
||||
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
|
||||
/// used instead.
|
||||
pub(crate) fn unwind_if_revision_cancelled(&self, db: &dyn Database) {
|
||||
let thread_id = std::thread::current().id();
|
||||
db.salsa_event(&|| Event {
|
||||
thread_id,
|
||||
|
||||
kind: EventKind::WillCheckCancellation,
|
||||
});
|
||||
db.salsa_event(&|| Event::new(EventKind::WillCheckCancellation));
|
||||
let zalsa = db.zalsa();
|
||||
if zalsa.load_cancellation_flag() {
|
||||
self.unwind_cancelled(zalsa.current_revision());
|
||||
|
|
Loading…
Reference in a new issue