pub struct MemoryFlush { /* private fields */ }Expand description
Memory flush controller.
Tracks whether a flush has been triggered in the current compaction cycle and provides methods to check if a flush is needed.
Implementations§
Source§impl MemoryFlush
impl MemoryFlush
Sourcepub fn new(config: MemoryFlushConfig) -> Self
pub fn new(config: MemoryFlushConfig) -> Self
Create a new memory flush controller.
Sourcepub fn should_flush(
&self,
current_tokens: usize,
max_tokens: usize,
compaction_threshold: f64,
) -> bool
pub fn should_flush( &self, current_tokens: usize, max_tokens: usize, compaction_threshold: f64, ) -> bool
Check if we should trigger a flush based on token count.
Returns true if:
- Memory flush is enabled
- We haven’t already flushed this cycle
- Current token count exceeds the soft threshold
Sourcepub fn build_flush_messages(&self) -> (String, String)
pub fn build_flush_messages(&self) -> (String, String)
Build the flush messages to inject.
Returns (system_message, user_message) with date/time substituted.
Sourcepub fn mark_flushed(&mut self)
pub fn mark_flushed(&mut self)
Mark that we’ve flushed this cycle.
Sourcepub fn reset_cycle(&mut self)
pub fn reset_cycle(&mut self)
Reset for a new compaction cycle.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if flush is enabled.
Auto Trait Implementations§
impl Freeze for MemoryFlush
impl RefUnwindSafe for MemoryFlush
impl Send for MemoryFlush
impl Sync for MemoryFlush
impl Unpin for MemoryFlush
impl UnsafeUnpin for MemoryFlush
impl UnwindSafe for MemoryFlush
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more