mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-08-04 02:48:38 +00:00
Move salsa event system into Zalsa
(#849)
* Move salsa event system into `Zalsa` * Encode `None` into ShallowUpdate This shrinks the return value from 16 to 8 bytes
This commit is contained in:
parent
f78a641d20
commit
cfa88e9a4d
35 changed files with 422 additions and 353 deletions
|
@ -87,9 +87,18 @@ struct LazyInputDatabase {
|
|||
|
||||
impl LazyInputDatabase {
|
||||
fn new(tx: Sender<DebounceEventResult>) -> Self {
|
||||
let logs: Arc<Mutex<Vec<String>>> = Default::default();
|
||||
Self {
|
||||
storage: Default::default(),
|
||||
logs: Default::default(),
|
||||
storage: Storage::new(Some(Box::new({
|
||||
let logs = logs.clone();
|
||||
move |event| {
|
||||
// don't log boring events
|
||||
if let salsa::EventKind::WillExecute { .. } = event.kind {
|
||||
logs.lock().unwrap().push(format!("{event:?}"));
|
||||
}
|
||||
}
|
||||
}))),
|
||||
logs,
|
||||
files: DashMap::new(),
|
||||
file_watcher: Arc::new(Mutex::new(
|
||||
new_debouncer(Duration::from_secs(1), tx).unwrap(),
|
||||
|
@ -99,15 +108,7 @@ impl LazyInputDatabase {
|
|||
}
|
||||
|
||||
#[salsa::db]
|
||||
impl salsa::Database for LazyInputDatabase {
|
||||
fn salsa_event(&self, event: &dyn Fn() -> salsa::Event) {
|
||||
// don't log boring events
|
||||
let event = event();
|
||||
if let salsa::EventKind::WillExecute { .. } = event.kind {
|
||||
self.logs.lock().unwrap().push(format!("{event:?}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
impl salsa::Database for LazyInputDatabase {}
|
||||
|
||||
#[salsa::db]
|
||||
impl Db for LazyInputDatabase {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue