Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::cpu_throttler Class Reference

Throttles operations based on CPU usage. More...

#include <resource_manager.h>

Collaboration diagram for kcenon::monitoring::cpu_throttler:
Collaboration graph

Public Member Functions

 cpu_throttler (const std::string &name, const cpu_throttle_config &config)
 
template<typename Func >
auto execute (Func &&func) -> decltype(func())
 Execute a function with CPU throttling.
 
resource_metrics get_metrics () const
 Get current metrics.
 
const std::string & get_name () const
 Get the name of this throttler.
 

Private Attributes

std::string name_
 
cpu_throttle_config config_
 
resource_metrics metrics_
 

Detailed Description

Throttles operations based on CPU usage.

Definition at line 412 of file resource_manager.h.

Constructor & Destructor Documentation

◆ cpu_throttler()

kcenon::monitoring::cpu_throttler::cpu_throttler ( const std::string & name,
const cpu_throttle_config & config )
inline

Definition at line 414 of file resource_manager.h.

415 : name_(name), config_(config) {}

Member Function Documentation

◆ execute()

template<typename Func >
auto kcenon::monitoring::cpu_throttler::execute ( Func && func) -> decltype(func())
inline

Execute a function with CPU throttling.

Template Parameters
FuncFunction type that returns common::Result<T>
Parameters
funcFunction to execute
Returns
Result of the function or error if throttled

Definition at line 424 of file resource_manager.h.

424 {
425 // For simplicity, we just execute the function and track metrics
426 // Real CPU monitoring would require platform-specific code
428
429 return std::forward<Func>(func)();
430 }

References metrics_, and kcenon::monitoring::resource_metrics::total_allocations.

◆ get_metrics()

resource_metrics kcenon::monitoring::cpu_throttler::get_metrics ( ) const
inline

Get current metrics.

Definition at line 435 of file resource_manager.h.

435 {
436 return metrics_;
437 }

References metrics_.

◆ get_name()

const std::string & kcenon::monitoring::cpu_throttler::get_name ( ) const
inline

Get the name of this throttler.

Definition at line 442 of file resource_manager.h.

442 {
443 return name_;
444 }

References name_.

Member Data Documentation

◆ config_

cpu_throttle_config kcenon::monitoring::cpu_throttler::config_
private

Definition at line 448 of file resource_manager.h.

◆ metrics_

resource_metrics kcenon::monitoring::cpu_throttler::metrics_
mutableprivate

Definition at line 449 of file resource_manager.h.

Referenced by execute(), and get_metrics().

◆ name_

std::string kcenon::monitoring::cpu_throttler::name_
private

Definition at line 447 of file resource_manager.h.

Referenced by get_name().


The documentation for this class was generated from the following file: