simplify salsa_event and make it dyn-safe

This commit is contained in:
Niko Matsakis 2020-07-02 10:48:49 +00:00
parent 67687376ed
commit d1fe9950c5
5 changed files with 10 additions and 11 deletions

View file

@ -188,7 +188,7 @@ where
if let Some(value) = memo.validate_memoized_value(db, revision_now) {
info!("{:?}: validated old memoized value", self,);
db.salsa_event(|| Event {
db.salsa_event(Event {
runtime_id: runtime.id(),
kind: EventKind::DidValidateMemoizedValue {
database_key: self.database_key_index,
@ -342,8 +342,8 @@ where
// Release our lock on `self.state`, so other thread can complete.
std::mem::drop(state);
db.salsa_event(|| Event {
runtime_id: db.salsa_runtime().id(),
db.salsa_event(Event {
runtime_id: runtime.id(),
kind: EventKind::WillBlockOn {
other_runtime_id: other_id,
database_key: self.database_key_index,

View file

@ -115,7 +115,7 @@ pub trait Database: plumbing::DatabaseStorageTypes + plumbing::DatabaseOps {
/// This function is invoked at key points in the salsa
/// runtime. It permits the database to be customized and to
/// inject logging or other custom behavior.
fn salsa_event(&self, event_fn: impl Fn() -> Event) {
fn salsa_event(&self, event_fn: Event) {
#![allow(unused_variables)]
}

View file

@ -313,10 +313,10 @@ impl Runtime {
database_key_index
);
db.salsa_event(|| Event {
runtime_id: db.salsa_runtime().id(),
db.salsa_event(Event {
runtime_id: self.id(),
kind: EventKind::WillExecute {
database_key: database_key_index.clone(),
database_key: database_key_index,
},
});

View file

@ -43,9 +43,9 @@ struct Database {
}
impl salsa::Database for Database {
fn salsa_event(&self, event_fn: impl Fn() -> salsa::Event) {
fn salsa_event(&self, event: salsa::Event) {
if let Some(cb) = &self.on_event {
cb(event_fn())
cb(event)
}
}
}

View file

@ -192,8 +192,7 @@ pub(crate) struct ParDatabaseImpl {
}
impl Database for ParDatabaseImpl {
fn salsa_event(&self, event_fn: impl Fn() -> salsa::Event) {
let event = event_fn();
fn salsa_event(&self, event: salsa::Event) {
match event.kind {
salsa::EventKind::WillBlockOn { .. } => {
self.signal(self.knobs().signal_on_will_block.get());