How to notify entities from different threads? #29784
Closed
JakkuSakura
started this conversation in
Zed GPUI
Replies: 2 comments 2 replies
-
Update of what? If there's a window that needs update, relatively costly way to do this is to call Lines 422 to 424 in f619d5f If a particular entity had updated, one could carry zed/crates/agent/src/active_thread.rs Lines 1570 to 1574 in f619d5f Not sure how the latter is supposed to work with Tokio though. |
Beta Was this translation helpful? Give feedback.
1 reply
-
I managed to do it with this pattern: let new = cx.new(move |_cx| AnyComponent::new(element));
let entity_id = new.entity_id();
let async_app = cx.to_async();
let func = move || {
if let Err(err) = async_app.update(|cx| cx.notify(entity_id)) {
error!("Failed to update entity: {}", err);
}
}; then func can be passed around |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
My app is multi-threaded tokio app, and I would like to notify the gpui when there's update. However,
gpui::App
is&mut
, which I couldn't use in other threads.How to notify entities from different threads?
Beta Was this translation helpful? Give feedback.
All reactions