Closed enelson1001 closed 2 years ago
You have to wrap your view manager in a STD Arc<Mutex<ViewManager>>
. Once you do this, you can clone it and then send the clones to other threads, where you can safely lock the manager due to the mutex and then call methods on the manager. Alternatively, you should make the view manager itself Sync
Send
and Clone
but thats more complex for a beginner. Regardless, it would be beneficial for you if you read about Send and Sync in Rust, as these concepts are key for the language.
If it is not clear, both the timer closure and the event loop closure are executed in separate threads.
Other points:
These questions btw beling to the Matrix channel. Youll get faster reaction there from many contributors. :)
I am new to rust. I am trying to retrieve the event_loop_message data outside the subscribe closure. Is there a way to do this? I can't use view_manager inside the closure as it take ownership and I need to use view_manger later.
This is what I have so far in main.rs. The "????" is how do I get the Bme280ReadMessage data outside the bme280_read_event_loop.subscribe closure.