I try to follow https://github.com/notify-rs/notify/blob/main/examples/async_monitor.rs, but there are some blocking thread like futures::executor::block_on
.
So I would like to use it without blocking execution.
tokio::task::spawn_blocking
can be the solution ?
I try
let (tx, mut rx) = tokio::sync::mpsc::channel(256);
let config = Config::default().with_poll_interval(duration::from_secs(2));
let mut watcher = PollWatcher::new(move |res| {
tx.send(res);
}, config,
).unwrap();
watcher.watch(Path::new("myfolder"), RecursiveMode::nonRecursive).unwrap();
tokio::task::spawn_blocking(move || {
while let Ok(Ok(file)) = rx.reicv() {
println!("File changed : {}", file); // Expected some logs here !
}
});
I can successfully start non blocking thread, but nothing is displayed, when folder is modified
SO what is wrong ?