Update README

This commit is contained in:
Pekka Enberg
2023-04-13 10:09:13 +03:00
parent 824669d471
commit 44ba56c5a8
2 changed files with 32 additions and 0 deletions

View File

@@ -10,6 +10,12 @@ Run tests:
cargo test
```
Test coverage report:
```console
cargo tarpaulin -o html
```
Run benchmarks:
```console

View 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)
}
}