refactor(sync): migrate remaining std mutex usage to parking_lot
This commit is contained in:
parent
5942caa083
commit
ef02f25c46
5 changed files with 54 additions and 81 deletions
|
|
@ -2,9 +2,9 @@ use super::sqlite::SqliteMemory;
|
|||
use super::traits::{Memory, MemoryCategory, MemoryEntry};
|
||||
use async_trait::async_trait;
|
||||
use chrono::Local;
|
||||
use parking_lot::Mutex;
|
||||
use std::collections::HashSet;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::process::Command;
|
||||
use tokio::time::timeout;
|
||||
|
|
@ -116,25 +116,20 @@ impl LucidMemory {
|
|||
}
|
||||
|
||||
fn in_failure_cooldown(&self) -> bool {
|
||||
let Ok(guard) = self.last_failure_at.lock() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let guard = self.last_failure_at.lock();
|
||||
guard
|
||||
.as_ref()
|
||||
.is_some_and(|last| last.elapsed() < self.failure_cooldown)
|
||||
}
|
||||
|
||||
fn mark_failure_now(&self) {
|
||||
if let Ok(mut guard) = self.last_failure_at.lock() {
|
||||
*guard = Some(Instant::now());
|
||||
}
|
||||
let mut guard = self.last_failure_at.lock();
|
||||
*guard = Some(Instant::now());
|
||||
}
|
||||
|
||||
fn clear_failure(&self) {
|
||||
if let Ok(mut guard) = self.last_failure_at.lock() {
|
||||
*guard = None;
|
||||
}
|
||||
let mut guard = self.last_failure_at.lock();
|
||||
*guard = None;
|
||||
}
|
||||
|
||||
fn to_lucid_type(category: &MemoryCategory) -> &'static str {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue