Debug pin macro (#118)

* debug pin macro

* Added debug pinning macro

* working on windows

* removed remaining box pins
This commit is contained in:
Wyatt Verchere
2023-05-18 10:31:52 -07:00
committed by GitHub
parent 0801d7a145
commit 16407060f0
35 changed files with 1133 additions and 990 deletions

View File

@@ -82,6 +82,8 @@ pub struct State {
impl State {
/// Get the current launcher state, initializing it if needed
#[tracing::instrument]
#[theseus_macros::debug_pin]
pub async fn get() -> crate::Result<Arc<Self>> {
LAUNCHER_STATE
.get_or_try_init(|| {
@@ -166,37 +168,35 @@ impl State {
}
#[tracing::instrument]
#[theseus_macros::debug_pin]
/// Synchronize in-memory state with persistent state
pub async fn sync() -> crate::Result<()> {
Box::pin(async move {
let state = Self::get().await?;
let sync_settings = async {
let state = Arc::clone(&state);
let state = Self::get().await?;
let sync_settings = async {
let state = Arc::clone(&state);
tokio::spawn(async move {
let reader = state.settings.read().await;
reader.sync(&state.directories.settings_file()).await?;
Ok::<_, crate::Error>(())
})
.await?
};
tokio::spawn(async move {
let reader = state.settings.read().await;
reader.sync(&state.directories.settings_file()).await?;
Ok::<_, crate::Error>(())
})
.await?
};
let sync_profiles = async {
let state = Arc::clone(&state);
let sync_profiles = async {
let state = Arc::clone(&state);
tokio::spawn(async move {
let profiles = state.profiles.read().await;
tokio::spawn(async move {
let profiles = state.profiles.read().await;
profiles.sync().await?;
Ok::<_, crate::Error>(())
})
.await?
};
profiles.sync().await?;
Ok::<_, crate::Error>(())
})
.await?
};
tokio::try_join!(sync_settings, sync_profiles)?;
Ok(())
})
.await
tokio::try_join!(sync_settings, sync_profiles)?;
Ok(())
}
/// Reset IO semaphore to default values