pub struct CognitiveTick { /* private fields */ }Expand description
The cognitive tick service.
Tracks per-tick compute timings, detects budget drift, and optionally adjusts the tick interval to maintain throughput under load.
Implementations§
Source§impl CognitiveTick
impl CognitiveTick
Sourcepub fn new(config: CognitiveTickConfig) -> Self
pub fn new(config: CognitiveTickConfig) -> Self
Create a new cognitive tick service with the given configuration.
Sourcepub fn with_interval(interval_ms: u32) -> Self
pub fn with_interval(interval_ms: u32) -> Self
Convenience constructor that creates a default config with a custom interval.
Sourcepub fn stats(&self) -> CognitiveTickStats
pub fn stats(&self) -> CognitiveTickStats
Return a point-in-time snapshot of statistics.
Sourcepub fn record_tick(&self, compute_us: u64)
pub fn record_tick(&self, compute_us: u64)
Record a tick with the given compute duration in microseconds.
This method:
- Increments the tick counter.
- Maintains a sliding window of recent timings.
- Updates the maximum observed compute time.
- Detects budget drift (compute exceeding the budget).
- Adaptively adjusts the tick interval if enabled.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether the tick loop is currently running.
Sourcepub fn set_running(&self, running: bool)
pub fn set_running(&self, running: bool)
Set the running state.
Sourcepub fn tick_count(&self) -> u64
pub fn tick_count(&self) -> u64
Total number of ticks recorded.
Sourcepub fn current_interval_ms(&self) -> u32
pub fn current_interval_ms(&self) -> u32
Current (possibly adapted) tick interval in milliseconds.
Sourcepub fn drift_count(&self) -> u64
pub fn drift_count(&self) -> u64
Number of ticks that exceeded the compute budget.
Trait Implementations§
Source§impl SystemService for CognitiveTick
impl SystemService for CognitiveTick
Source§fn service_type(&self) -> ServiceType
fn service_type(&self) -> ServiceType
Service type category.
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the service.
Source§fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop the service.
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = HealthStatus> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform a health check.
Auto Trait Implementations§
impl !Freeze for CognitiveTick
impl RefUnwindSafe for CognitiveTick
impl Send for CognitiveTick
impl Sync for CognitiveTick
impl Unpin for CognitiveTick
impl UnsafeUnpin for CognitiveTick
impl UnwindSafe for CognitiveTick
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more