rib commented on code in PR #7000:
URL: https://github.com/apache/opendal/pull/7000#discussion_r2623759293
##########
bindings/java/src/executor.rs:
##########
@@ -116,24 +116,45 @@ pub unsafe extern "system" fn
Java_org_apache_opendal_AsyncExecutor_disposeInter
}
pub(crate) fn make_tokio_executor(env: &mut JNIEnv, cores: usize) ->
Result<Executor> {
- let vm = env.get_java_vm().expect("JavaVM must be available");
+ let vm = Arc::new(env.get_java_vm().expect("JavaVM must be available"));
let counter = AtomicUsize::new(0);
let executor = tokio::runtime::Builder::new_multi_thread()
.worker_threads(cores)
.thread_name_fn(move || {
let id = counter.fetch_add(1, Ordering::SeqCst);
format!("opendal-tokio-worker-{id}")
})
- .on_thread_start(move || {
- ENV.with(|cell| {
- let mut env = vm
- .attach_current_thread_as_daemon()
- .expect("attach thread must succeed");
+ .on_thread_start({
+ let vm = vm.clone();
+ move || {
+ ENV.with(|cell| {
+ let mut env = vm
+ .attach_current_thread_as_daemon()
Review Comment:
Okey, now that I have [a PR open](https://github.com/jni-rs/jni-rs/pull/718)
to address issue https://github.com/jni-rs/jni-rs/issues/701 (referenced from
#6869) I've also updated the draft release-0.22 branch which has the version
bumped to 0.22 (ref: https://github.com/jni-rs/jni-rs/pull/650).
It would be great if you're able to test the jni 0.22 API with a real-world
use case before it's released and I can do my best to help if you hit any
issues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]