aggressively clean up desktop with new inline poll

This commit is contained in:
Jonathan Kelley committed 2022-12-30 01:08:25 -05:00
1 parent 7bc8150da7
commit 633bf1f834
7 files changed
+325 -382

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
use futures_util::task::ArcWake;
use std::sync::Arc;
use wry::application::event_loop::EventLoopProxy;
use crate::desktop_context::UserWindowEvent;
/// Create a waker that will send a poll event to the event loop.
///
/// This lets the VirtualDom "come up for air" and process events while the main thread is blocked by the WebView.
///
/// All other IO lives in the Tokio runtime,
pub fn tao_waker(proxy: &EventLoopProxy<UserWindowEvent>) -> std::task::Waker {
struct DomHandle(EventLoopProxy<UserWindowEvent>);
impl ArcWake for DomHandle {
fn wake_by_ref(arc_self: &Arc<Self>) {
arc_self.0.send_event(UserWindowEvent::Poll).unwrap();
}
}
futures_util::task::waker(Arc::new(DomHandle(proxy.clone())))
}