Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call uninit in stop function to avoid AlreadyRunning error #76

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

duanyytop
Copy link
Collaborator

@duanyytop duanyytop commented Dec 26, 2024

static INITIALIZED: once_cell::sync::Lazy<Mutex<bool>> =
    once_cell::sync::Lazy::new(|| Mutex::new(false));

#[cfg(test)]
async fn uninit() {
    let mut init = INITIALIZED.lock().await;
    *init = false;
}

impl MutinyWallet {
    pub async fn new(
    ...
    ) {
        ...
        if *init {
             return Err(MutinyJsError::AlreadyRunning);
         } else {
             *init = true;
         }
         ...
   }     
}

@duanyytop duanyytop changed the title Call uninit in stop function to avoid AlreadyRunning Call uninit in stop function to avoid AlreadyRunning error Dec 26, 2024
@duanyytop duanyytop merged commit b0e27b6 into develop Dec 26, 2024
9 checks passed
@duanyytop duanyytop deleted the ref/stop-uninit branch December 26, 2024 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants