Start the LSP thread when the gui thread is ready

This way we can serve preview requests immediately.

This basically makes post_event safe to call before the event loop is entered.
The events will be queued up and sent when the event loop
is created and we have access
to the proxy, which will take over the queue.
This commit is contained in:
Simon Hausmann 2021-04-06 11:38:09 +02:00
parent d9db07db2a
commit b81803774b
4 changed files with 65 additions and 26 deletions

View file

@ -1520,12 +1520,7 @@ impl sixtyfps_corelib::backend::Backend for Backend {
fn post_event(&'static self, event: Box<dyn FnOnce() + Send>) {
let e = crate::eventloop::CustomEvent::UserEvent(event);
#[cfg(not(target_arch = "wasm32"))]
crate::eventloop::GLOBAL_PROXY
.get_or_init(Default::default)
.lock()
.unwrap()
.as_ref()
.map(|proxy| proxy.send_event(e));
crate::eventloop::GLOBAL_PROXY.get_or_init(Default::default).lock().unwrap().send_event(e);
#[cfg(target_arch = "wasm32")]
crate::eventloop::with_window_target(|event_loop| {
event_loop.event_loop_proxy().send_event(e).ok();