Use futures_util mutex instead of flume for sending flush lock wakeups

This commit is contained in:
Jonathan Kelley committed 2024-02-02 13:09:26 -08:00
1 parent 38bdab880d
commit 8f70a84c70
14 files changed
+100 -43

No files matched your search

+5 -7
View File
@@ -1,5 +1,5 @@
use crate::{runtime::Runtime, Element, ScopeId, Task};
use futures_util::{future::poll_fn, Future};
use futures_util::Future;
use std::sync::Arc;
/// Get the current scope id
@@ -257,13 +257,11 @@ pub fn after_render(f: impl FnMut() + 'static) {
/// Effects rely on this to ensure that they only run effects after the DOM has been updated. Without flush_sync effects
/// are run immediately before diffing the DOM, which causes all sorts of out-of-sync weirdness.
pub async fn flush_sync() {
// if flushing() {
// return;
// }
_ = Runtime::with(|rt| rt.flush.clone())
// Wait for the flush lock to be available
// We release it immediately, so it's impossible for the lock to be held longer than this function
Runtime::with(|rt| rt.flush_mutex.clone())
.unwrap()
.recv_async()
.lock()
.await;
}