[PERF] Host Debug Overlay Isolation
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
use crate::log::{LogEvent, LogLevel, LogSource};
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct LogService {
|
||||
events: VecDeque<LogEvent>,
|
||||
capacity: usize,
|
||||
next_seq: u64,
|
||||
pub logs_count: u32,
|
||||
pub logs_count: Arc<AtomicU32>,
|
||||
}
|
||||
|
||||
impl LogService {
|
||||
pub fn new(capacity: usize) -> Self {
|
||||
Self { events: VecDeque::with_capacity(capacity), capacity, next_seq: 0, logs_count: 0 }
|
||||
Self {
|
||||
events: VecDeque::with_capacity(capacity),
|
||||
capacity,
|
||||
next_seq: 0,
|
||||
logs_count: Arc::new(AtomicU32::new(0)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log(
|
||||
@@ -35,11 +42,11 @@ impl LogService {
|
||||
msg,
|
||||
});
|
||||
self.next_seq += 1;
|
||||
self.logs_count += 1;
|
||||
self.logs_count.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn reset_count(&mut self) {
|
||||
self.logs_count = 0;
|
||||
self.logs_count.store(0, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn get_recent(&self, n: usize) -> Vec<LogEvent> {
|
||||
|
||||
Reference in New Issue
Block a user