fix(event loop, client): better async

This commit is contained in:
Nova
2023-01-14 12:38:05 -05:00
parent 198b342dec
commit 27d75d3098
7 changed files with 171 additions and 133 deletions

View File

@@ -192,23 +192,25 @@ impl InputHandler {
let handler = Arc::downgrade(&distance_link.handler);
if let Ok(data) = node.execute_remote_method("input", data) {
tokio::spawn(async move {
if let Ok(data) = data.await {
if frame == FRAME.load(Ordering::Relaxed) {
let capture = flexbuffers::Reader::get_root(data.as_slice())
.and_then(|data| data.get_bool())
.unwrap_or(false);
let _ = tokio::task::Builder::new()
.name("input capture")
.spawn(async move {
if let Ok(data) = data.await {
if frame == FRAME.load(Ordering::Relaxed) {
let capture = flexbuffers::Reader::get_root(data.as_slice())
.and_then(|data| data.get_bool())
.unwrap_or(false);
if let Some(method) = method.upgrade() {
if let Some(handler) = handler.upgrade() {
if capture {
method.captures.add_raw(&handler);
if let Some(method) = method.upgrade() {
if let Some(handler) = handler.upgrade() {
if capture {
method.captures.add_raw(&handler);
}
}
}
}
}
}
});
});
}
}
}