mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 08:55:40 +01:00
Update README
This commit is contained in:
@@ -10,6 +10,12 @@ Run tests:
|
||||
cargo test
|
||||
```
|
||||
|
||||
Test coverage report:
|
||||
|
||||
```console
|
||||
cargo tarpaulin -o html
|
||||
```
|
||||
|
||||
Run benchmarks:
|
||||
|
||||
```console
|
||||
|
||||
26
core/mvcc/database/src/clock.rs
Normal file
26
core/mvcc/database/src/clock.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
/// Logical clock.
|
||||
pub trait LogicalClock {
|
||||
fn get_timestamp(&self) -> u64;
|
||||
}
|
||||
|
||||
/// A node-local clock backed by an atomic counter.
|
||||
#[derive(Debug, Default)]
|
||||
pub struct LocalClock {
|
||||
ts_sequence: AtomicU64,
|
||||
}
|
||||
|
||||
impl LocalClock {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
ts_sequence: AtomicU64::new(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LogicalClock for LocalClock {
|
||||
fn get_timestamp(&self) -> u64 {
|
||||
self.ts_sequence.fetch_add(1, Ordering::SeqCst)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user