Struct Memory

Source
pub struct Memory {
    config: MemoryConfig,
}
Expand description

The main struct for the memory monitoring thread.

An instance of this struct contains the configuration and the state required to perform periodic memory checks.

Fields§

§config: MemoryConfig

configuration read from .toml file

Implementations§

Source§

impl Memory

Source

pub fn new(config: MemoryConfig) -> Result<Memory, MemoryConfigError>

Creates a new Memory instance.

Stores the configuration and initializes the lock flags.

§Arguments
  • config - A reference to the global ConfigData containing the memory configuration.
§Returns

A new Memory instance wrapped in a Result type ready to be executed in its own thread.

Source

pub fn execute(&mut self, memory_channels: &mut MemoryChannels)

Starts the memory monitoring loop.

  1. Checks for a Quit command from the signal handler to terminate gracefully.
  2. Checks the current resident and allocated memory usage against configured limits.
  3. Logs a warning if any limit is exceeded.
  4. Sleeps for the configured interval before the next check.
§Arguments
  • memory_channels - A mutable reference to the channels used for receiving shutdown commands.

Trait Implementations§

Source§

impl ProcessExternalRequestTrait for Memory

Source§

fn process_external_request( &mut self, rx_from_signal_handler: &mut AquaReceiver<InternalCommand>, _: Option<&mut AquaReceiver<InternalCommand>>, ) -> (bool, bool, bool)

Checks for and processes new commands relevant to the Memory module from external channels.

This is the specialized implementation of ProcessExternalRequestTrait for TcpCommunication. It delegates directly to process_external_request_without_messaging, indicating that the Memory module primarily processes commands from the signal handler and does not use a separate messaging channel for external requests.

§Arguments
  • rx_from_memory - A reference to the receiver end of the channel for commands originating from the signal handler.
  • _ - This parameter is ignored, as the Memory module does not process messages from a messaging channel in this context.
§Returns

A tuple (bool, bool, bool) indicating the status of commands received:

  • The first bool is true if a Quit command was received; otherwise false.
  • The second bool is always false (no “Start” commands processed).
  • The third bool is always false (no “Stop” commands processed).

Auto Trait Implementations§

§

impl Freeze for Memory

§

impl RefUnwindSafe for Memory

§

impl Send for Memory

§

impl Sync for Memory

§

impl Unpin for Memory

§

impl UnwindSafe for Memory

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T