chore: remove unused clock and mutex helpers
This commit is contained in:
2 files changed
+1
-20
No files matched your search
@@ -14,16 +14,11 @@ pub trait Clock {
|
||||
}
|
||||
|
||||
pub enum Realtime {}
|
||||
pub enum Monotonic {}
|
||||
|
||||
impl Clock for Realtime {
|
||||
const ID: ClockId = ClockId::Realtime;
|
||||
}
|
||||
|
||||
impl Clock for Monotonic {
|
||||
const ID: ClockId = ClockId::Monotonic;
|
||||
}
|
||||
|
||||
pub struct ClockSample<C> {
|
||||
time_s: u64,
|
||||
time_ns: u64,
|
||||
@@ -56,10 +51,6 @@ impl<C: Clock> ClockSample<C> {
|
||||
pub fn as_secs_f64(&self) -> f64 {
|
||||
self.time_s as f64 + self.time_ns as f64 / 1_000_000_000.0
|
||||
}
|
||||
|
||||
pub fn to_milliseconds(&self) -> u64 {
|
||||
(self.time_s * 1000) + (self.time_ns / 1000000)
|
||||
}
|
||||
}
|
||||
|
||||
impl ClockSample<Realtime> {
|
||||
|
||||
+1
-11
@@ -3,20 +3,10 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use anyhow::anyhow;
|
||||
use std::sync::{Arc, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
|
||||
|
||||
pub type ArcRwLock<T> = Arc<RwLock<T>>;
|
||||
|
||||
pub trait MutexExt<T> {
|
||||
fn lock_anyhow(&self) -> anyhow::Result<MutexGuard<'_, T>>;
|
||||
}
|
||||
|
||||
impl<T> MutexExt<T> for Mutex<T> {
|
||||
fn lock_anyhow(&self) -> anyhow::Result<MutexGuard<'_, T>> {
|
||||
self.lock().map_err(|e| anyhow!("mutex poisoned: {e}"))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RwLockExt<T> {
|
||||
fn read_anyhow(&self) -> anyhow::Result<RwLockReadGuard<'_, T>>;
|
||||
fn write_anyhow(&self) -> anyhow::Result<RwLockWriteGuard<'_, T>>;
|
||||
|
||||
Reference in new issue
Block a user