mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-02 11:06:14 +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,
|
||||
observer: Arc<Observer>,
|
||||
diff_calculator: Arc<Mutex<DiffCalculator>>,
|
||||
// when dropping the doc, the txn will be commited
|
||||
txn: Arc<Mutex<Option<Transaction>>>,
|
||||
auto_commit: bool,
|
||||
detached: bool,
|
||||
}
|
||||
|
||||
impl Default for LoroDoc {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl LoroDoc {
|
||||
pub fn new() -> Self {
|
||||
let oplog = OpLog::new();
|
||||
|
@ -664,18 +671,6 @@ fn parse_encode_header(bytes: &[u8]) -> Result<(&[u8], EncodeMode), LoroError> {
|
|||
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)]
|
||||
mod test {
|
||||
use loro_common::ID;
|
||||
|
|
Loading…
Reference in a new issue