aggressively clean up desktop with new inline poll
This commit is contained in:
1 parent
7bc8150da7
commit
633bf1f834
7 files changed
+325
-382
No files matched your search
@@ -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())))
|
||||
}
|
||||
Reference in new issue
Block a user