Skip to content

Commit

Permalink
make JavaVM Atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
shiroedev2024 committed Apr 23, 2024
1 parent 71d1bb7 commit 1c02b40
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 53 deletions.
109 changes: 58 additions & 51 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions doh/src/mobile/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@
#[cfg(target_os = "android")]
pub mod android {
use std::os::unix::io::RawFd;
use std::sync::{Arc, Mutex};

use anyhow::{anyhow, Result};
use jni::{objects::*, JavaVM};
use std::sync::RwLock;

static JVM: RwLock<Option<JavaVM>> = RwLock::new(None);
static JVM: RwLock<Option<Arc<JavaVM>>> = RwLock::new(None);
static CALLBACK_PROTECT_SOCKET: RwLock<Option<CallbackProtectSocket>> = RwLock::new(None);

struct CallbackProtectSocket {
class: GlobalRef,
name: String,
}

pub fn set_jvm(vm: JavaVM) {
pub fn set_jvm(vm: Arc<JavaVM>) {
*JVM.write().unwrap() = Some(vm);
}

Expand Down

0 comments on commit 1c02b40

Please sign in to comment.