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

Configuration for memory pool. More...

#include <memory_pool.h>

Collaboration diagram for kcenon::monitoring::memory_pool_config:
Collaboration graph

Public Member Functions

bool validate () const
 Validate configuration.
 

Public Attributes

size_t initial_blocks = 256
 Initial number of blocks.
 
size_t max_blocks = 4096
 Maximum number of blocks (0 = unlimited)
 
size_t block_size = 64
 Size of each block in bytes.
 
size_t alignment = 8
 Memory alignment (must be power of 2)
 
bool use_thread_local_cache = false
 Use thread-local caching.
 

Detailed Description

Configuration for memory pool.

Definition at line 67 of file memory_pool.h.

Member Function Documentation

◆ validate()

bool kcenon::monitoring::memory_pool_config::validate ( ) const
inline

Validate configuration.

Returns
true if configuration is valid

Definition at line 78 of file memory_pool.h.

78 {
79 if (initial_blocks == 0) {
80 return false;
81 }
82 if (max_blocks != 0 && max_blocks < initial_blocks) {
83 return false;
84 }
85 if (block_size == 0) {
86 return false;
87 }
88 // Block size must be 8-byte aligned
89 if (block_size % 8 != 0) {
90 return false;
91 }
92 // Alignment must be power of 2
93 if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
94 return false;
95 }
96 return true;
97 }
size_t block_size
Size of each block in bytes.
Definition memory_pool.h:70
size_t alignment
Memory alignment (must be power of 2)
Definition memory_pool.h:71
size_t max_blocks
Maximum number of blocks (0 = unlimited)
Definition memory_pool.h:69
size_t initial_blocks
Initial number of blocks.
Definition memory_pool.h:68

References alignment, block_size, initial_blocks, and max_blocks.

Referenced by TEST_F(), and TEST_F().

Here is the caller graph for this function:

Member Data Documentation

◆ alignment

size_t kcenon::monitoring::memory_pool_config::alignment = 8

Memory alignment (must be power of 2)

Definition at line 71 of file memory_pool.h.

Referenced by kcenon::monitoring::memory_pool::grow_pool(), kcenon::monitoring::memory_pool::initialize_pool(), TEST_F(), and validate().

◆ block_size

size_t kcenon::monitoring::memory_pool_config::block_size = 64

Size of each block in bytes.

Definition at line 70 of file memory_pool.h.

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and validate().

◆ initial_blocks

size_t kcenon::monitoring::memory_pool_config::initial_blocks = 256

Initial number of blocks.

Definition at line 68 of file memory_pool.h.

Referenced by kcenon::monitoring::memory_pool::is_owned_block(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and validate().

◆ max_blocks

size_t kcenon::monitoring::memory_pool_config::max_blocks = 4096

Maximum number of blocks (0 = unlimited)

Definition at line 69 of file memory_pool.h.

Referenced by kcenon::monitoring::memory_pool::grow_pool(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and validate().

◆ use_thread_local_cache

bool kcenon::monitoring::memory_pool_config::use_thread_local_cache = false

Use thread-local caching.

Definition at line 72 of file memory_pool.h.

Referenced by TEST_F().


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