Switch Connection to use Arc instead of Rc

Connection needs to be Arc so that bindings can wrap it with `Mutex` for
multi-threading.
This commit is contained in:
Pekka Enberg 2025-06-16 10:08:00 +03:00
parent 7e9a25ebca
commit 90c1e3fc06
32 changed files with 124 additions and 187 deletions

View file

@ -8,19 +8,16 @@ use jni::objects::{JByteArray, JObject};
use jni::sys::jlong;
use jni::JNIEnv;
use limbo_core::Connection;
use std::rc::Rc;
use std::sync::Arc;
#[derive(Clone)]
pub struct LimboConnection {
// Because java's LimboConnection is 1:1 mapped to limbo connection, we can use Rc
pub(crate) conn: Rc<Connection>,
// Because io is shared across multiple `LimboConnection`s, wrap it with Arc
pub(crate) conn: Arc<Connection>,
pub(crate) io: Arc<dyn limbo_core::IO>,
}
impl LimboConnection {
pub fn new(conn: Rc<Connection>, io: Arc<dyn limbo_core::IO>) -> Self {
pub fn new(conn: Arc<Connection>, io: Arc<dyn limbo_core::IO>) -> Self {
LimboConnection { conn, io }
}