mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
19 lines
490 B
Rust
19 lines
490 B
Rust
use std::sync::atomic::{AtomicU64, Ordering};
|
|
|
|
use yazi_shared::id::Id;
|
|
|
|
pub struct Behavior {
|
|
first_id: AtomicU64,
|
|
}
|
|
|
|
impl Behavior {
|
|
pub(super) fn new() -> Self { Self { first_id: AtomicU64::new(0) } }
|
|
|
|
pub(super) fn update(&self, id: Id) {
|
|
self.first_id.compare_exchange(0, id.get(), Ordering::Relaxed, Ordering::Relaxed).ok();
|
|
}
|
|
|
|
pub fn reset(&self) { self.first_id.store(0, Ordering::Relaxed); }
|
|
|
|
pub fn first_id(&self) -> Id { self.first_id.load(Ordering::Relaxed).into() }
|
|
}
|