chore(java): try_recv async

This commit is contained in:
zaaarf 2024-08-14 00:27:26 +02:00
parent a9d713fd75
commit bd6423856b
No known key found for this signature in database
GPG key ID: 102E445F4C3F829B
2 changed files with 4 additions and 3 deletions

View file

@ -41,7 +41,7 @@ pub extern "system" fn Java_mp_code_BufferController_try_1recv(
self_ptr: jlong,
) -> jobject {
let controller = unsafe { Box::leak(Box::from_raw(self_ptr as *mut crate::buffer::Controller)) };
let change = controller.try_recv().jexcept(&mut env);
let change = RT.block_on(controller.try_recv()).jexcept(&mut env);
recv_jni(&mut env, change)
}
@ -101,7 +101,8 @@ pub extern "system" fn Java_mp_code_BufferController_send<'local>(
controller.send(crate::api::TextChange {
start: start as u32,
end: end as u32,
content
content,
hash: None
}).jexcept(&mut env);
}

View file

@ -11,7 +11,7 @@ pub extern "system" fn Java_mp_code_CursorController_try_1recv(
self_ptr: jlong,
) -> jobject {
let controller = unsafe { Box::leak(Box::from_raw(self_ptr as *mut crate::cursor::Controller)) };
let cursor = controller.try_recv().jexcept(&mut env);
let cursor = RT.block_on(controller.try_recv()).jexcept(&mut env);
jni_recv(&mut env, cursor)
}