Skip to content

Commit

Permalink
Merge pull request #109 from nazar-pc/remove-atomic-dependency
Browse files Browse the repository at this point in the history
Remove `atomic` crate from dependencies
  • Loading branch information
nazar-pc authored Feb 2, 2024
2 parents 1252e62 + 00aee05 commit 5d4ddff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ product-name = "Space Acres"
anyhow = "1.0.79"
arc-swap = "1.6.0"
async-trait = "0.1.77"
atomic = "0.5.3"
bytesize = "1.3.0"
clap = { version = "4.4.18", features = ["derive"] }
dark-light = "1.0.0"
Expand Down
17 changes: 7 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::frontend::configuration::{ConfigurationInput, ConfigurationOutput, Co
use crate::frontend::loading::{LoadingInput, LoadingView};
use crate::frontend::new_version::NewVersion;
use crate::frontend::running::{RunningInput, RunningView};
use atomic::Atomic;
use clap::Parser;
use duct::cmd;
use file_rotate::compression::Compression;
Expand All @@ -19,14 +18,14 @@ use file_rotate::{ContentLimit, FileRotate};
use futures::channel::mpsc;
use futures::{select, FutureExt, SinkExt, StreamExt};
use gtk::prelude::*;
use parking_lot::Mutex;
use relm4::prelude::*;
use relm4::{Sender, ShutdownReceiver, RELM_THREADS};
use relm4_icons::icon_name;
use std::future::Future;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::process::{ExitCode, Termination};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread::available_parallelism;
use std::{env, fs, io, process};
Expand Down Expand Up @@ -167,7 +166,7 @@ impl StatusBarNotification {
}

struct AppInit {
exit_status_code: Arc<Atomic<AppStatusCode>>,
exit_status_code: Arc<Mutex<AppStatusCode>>,
minimize_on_start: bool,
}

Expand All @@ -183,7 +182,7 @@ struct App {
running_view: Controller<RunningView>,
menu_popover: gtk::Popover,
about_dialog: gtk::AboutDialog,
exit_status_code: Arc<Atomic<AppStatusCode>>,
exit_status_code: Arc<Mutex<AppStatusCode>>,
// Stored here so `Drop` is called on this future as well, preventing exit until everything shuts down gracefully
_background_tasks: Box<dyn Future<Output = ()>>,
}
Expand Down Expand Up @@ -548,8 +547,7 @@ impl AsyncComponent for App {
self.current_view = View::Loading;
}
AppInput::Restart => {
self.exit_status_code
.store(AppStatusCode::Restart, Ordering::Release);
*self.exit_status_code.lock() = AppStatusCode::Restart;
relm4::main_application().quit();
}
}
Expand Down Expand Up @@ -684,8 +682,7 @@ impl App {
self.process_backend_notification(notification);
}
AppCommandOutput::Restart => {
self.exit_status_code
.store(AppStatusCode::Restart, Ordering::Release);
*self.exit_status_code.lock() = AppStatusCode::Restart;
relm4::main_application().quit();
}
}
Expand Down Expand Up @@ -818,14 +815,14 @@ impl Cli {
}
}

let exit_status_code = Arc::new(Atomic::new(AppStatusCode::Exit));
let exit_status_code = Arc::new(Mutex::new(AppStatusCode::Exit));

app.run_async::<App>(AppInit {
exit_status_code: Arc::clone(&exit_status_code),
minimize_on_start: self.startup,
});

let exit_status_code = exit_status_code.load(Ordering::Acquire);
let exit_status_code = *exit_status_code.lock();
info!(
?exit_status_code,
"Exiting {} {}",
Expand Down

0 comments on commit 5d4ddff

Please sign in to comment.