In EGUI, I have another thread that needs to continuously update a "vec! [..]" data, which needs to be synchronously updated and displayed in the EGUI window. Do you have any good ideas or similar examples for reference.
The 'unsafe' method can also be accepted without affecting performance.
Feeling endless!
eframe="0.22.0"
I am also considering using 'Arc<Mutex/RwLock>>'. But we always encounter work issues, such as ownership and lifecycle issues.
If it's convenient for you, could you provide an example of home! Let me refer to it. Thank you very much!!!
You will likely need to have both the UI and backend thread maintain a copy of the data; this is inherent in what you're asking for. If the UI is reading while the background thread is writing, this must be to different parts of memory for you to not get incomplete results (at best)
A very simple option is to create a channel that sends the updated values from the backend, and in render pull any updates before rendering. Specifically, you want to use the bounded sync_channel, and use try_recv until it returns an error.
The details are highly specific to what you're trying to do though: if this vec is millions of items long, you probably don't want to be copying it continuously, for example. You can look into double or triple buffering approaches, but they are probably not needed here.