Merge pull request #208 from pan93412/ready-to-atomic

refactor(core): 🐛 Use AtomicBool for READY
This commit is contained in:
Observer KRypt0n_ 2023-07-05 18:41:33 +02:00 committed by GitHub
commit 88b1344937
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 7 deletions

View file

@ -27,13 +27,13 @@ pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const APP_DEBUG: bool = cfg!(debug_assertions);
/// Sets to `true` when the `App` component is ready (fully initialized)
pub static mut READY: bool = false;
pub static READY: AtomicBool = AtomicBool::new(false);
// TODO: get rid of using this function in all the components' events
// e.g. by converting preferences pages into Relm4 Components
/// Check if the app is ready
pub fn is_ready() -> bool {
unsafe { READY }
READY.load(Ordering::Relaxed)
}
lazy_static::lazy_static! {

View file

@ -174,10 +174,10 @@ impl SimpleComponent for FirstRunApp {
unsafe {
MAIN_WINDOW = Some(widgets.window.clone());
crate::READY = true;
}
crate::READY.store(true, Ordering::Relaxed);
tracing::info!("First run window initialized. App is ready");
ComponentParts { model, widgets } // will return soon

View file

@ -873,9 +873,7 @@ impl SimpleComponent for App {
});
// Mark app as loaded
unsafe {
crate::READY = true;
}
crate::READY.store(true, Ordering::Relaxed);
tracing::info!("App is ready");
});