mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-11 14:53:12 +00:00
fix: commit txn when dropping
it's less confusing
This commit is contained in:
parent
a68482a495
commit
93a52ba55e
1 changed files with 7 additions and 12 deletions
|
@ -52,11 +52,18 @@ pub struct LoroDoc {
|
||||||
arena: SharedArena,
|
arena: SharedArena,
|
||||||
observer: Arc<Observer>,
|
observer: Arc<Observer>,
|
||||||
diff_calculator: Arc<Mutex<DiffCalculator>>,
|
diff_calculator: Arc<Mutex<DiffCalculator>>,
|
||||||
|
// when dropping the doc, the txn will be commited
|
||||||
txn: Arc<Mutex<Option<Transaction>>>,
|
txn: Arc<Mutex<Option<Transaction>>>,
|
||||||
auto_commit: bool,
|
auto_commit: bool,
|
||||||
detached: bool,
|
detached: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for LoroDoc {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl LoroDoc {
|
impl LoroDoc {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let oplog = OpLog::new();
|
let oplog = OpLog::new();
|
||||||
|
@ -664,18 +671,6 @@ fn parse_encode_header(bytes: &[u8]) -> Result<(&[u8], EncodeMode), LoroError> {
|
||||||
Ok((&input[1..], mode))
|
Ok((&input[1..], mode))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LoroDoc {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for LoroDoc {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
self.abort_txn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use loro_common::ID;
|
use loro_common::ID;
|
||||||
|
|
Loading…
Reference in a new issue