Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::integration::thread_integration_manager Class Reference

Manager for thread system integration. More...

#include <thread_integration.h>

Collaboration diagram for kcenon::network::integration::thread_integration_manager:
Collaboration graph

Classes

class  impl
 
struct  metrics
 Get thread pool metrics. More...
 

Public Member Functions

void set_thread_pool (std::shared_ptr< thread_pool_interface > pool)
 Set the thread pool implementation.
 
std::shared_ptr< thread_pool_interfaceget_thread_pool ()
 Get the current thread pool.
 
std::future< void > submit_task (std::function< void()> task)
 Submit a task to the thread pool.
 
std::future< void > submit_delayed_task (std::function< void()> task, std::chrono::milliseconds delay)
 Submit a task with delay.
 
metrics get_metrics () const
 Get current metrics.
 

Static Public Member Functions

static thread_integration_managerinstance ()
 Get the singleton instance.
 

Private Member Functions

 thread_integration_manager ()
 
 ~thread_integration_manager ()
 

Private Attributes

std::shared_ptr< implpimpl_
 PIMPL pointer with intentional leak pattern.
 

Detailed Description

Manager for thread system integration.

This class manages the integration between network_system and thread pool implementations.

Definition at line 143 of file thread_integration.h.

Constructor & Destructor Documentation

◆ thread_integration_manager()

kcenon::network::integration::thread_integration_manager::thread_integration_manager ( )
private

Definition at line 506 of file thread_integration.cpp.

511 : pimpl_(new impl(), [](impl*) { /* no-op deleter - intentional leak */ }) {
512}
std::shared_ptr< impl > pimpl_
PIMPL pointer with intentional leak pattern.

◆ ~thread_integration_manager()

kcenon::network::integration::thread_integration_manager::~thread_integration_manager ( )
privatedefault

Member Function Documentation

◆ get_metrics()

thread_integration_manager::metrics kcenon::network::integration::thread_integration_manager::get_metrics ( ) const

Get current metrics.

Returns
Current thread pool metrics

Definition at line 539 of file thread_integration.cpp.

539 {
540 return pimpl_->get_metrics();
541}

References pimpl_.

◆ get_thread_pool()

std::shared_ptr< thread_pool_interface > kcenon::network::integration::thread_integration_manager::get_thread_pool ( )

Get the current thread pool.

Returns
Current thread pool (creates basic pool if none set)

Definition at line 522 of file thread_integration.cpp.

522 {
523 return pimpl_->get_thread_pool();
524}

References pimpl_.

Referenced by kcenon::network::integration::ThreadPoolBridge::from_thread_system(), and kcenon::network::integration::messaging_bridge::get_thread_pool_interface().

Here is the caller graph for this function:

◆ instance()

thread_integration_manager & kcenon::network::integration::thread_integration_manager::instance ( )
static

◆ set_thread_pool()

void kcenon::network::integration::thread_integration_manager::set_thread_pool ( std::shared_ptr< thread_pool_interface > pool)

Set the thread pool implementation.

Parameters
poolThread pool to use

Definition at line 516 of file thread_integration.cpp.

518 {
519 pimpl_->set_thread_pool(pool);
520}

References pimpl_.

◆ submit_delayed_task()

std::future< void > kcenon::network::integration::thread_integration_manager::submit_delayed_task ( std::function< void()> task,
std::chrono::milliseconds delay )

Submit a task with delay.

Parameters
taskThe task to execute
delayDelay before execution
Returns
Future for the task result

Definition at line 532 of file thread_integration.cpp.

535 {
536 return pimpl_->submit_delayed_task(task, delay);
537}

References pimpl_.

Referenced by kcenon::network::utils::memory_profiler::schedule_next_sample().

Here is the caller graph for this function:

◆ submit_task()

std::future< void > kcenon::network::integration::thread_integration_manager::submit_task ( std::function< void()> task)

Submit a task to the thread pool.

Parameters
taskThe task to execute
Returns
Future for the task result

Definition at line 526 of file thread_integration.cpp.

528 {
529 return pimpl_->submit_task(task);
530}

References pimpl_.

Referenced by kcenon::network::protocols::grpc::grpc_client::impl::call_raw_async(), and kcenon::network::utils::health_monitor::start_monitoring().

Here is the caller graph for this function:

Member Data Documentation

◆ pimpl_

std::shared_ptr<impl> kcenon::network::integration::thread_integration_manager::pimpl_
private

PIMPL pointer with intentional leak pattern.

Uses shared_ptr with no-op deleter to prevent heap corruption during static destruction. This is intentional - see docs/DESIGN_DECISIONS.md for detailed rationale.

Note
Memory is intentionally not freed. This is safe because:
  • Only ~100-200 bytes per singleton instance
  • Process terminates immediately after static destruction
  • OS reclaims all process memory on exit
Warning
Do not "fix" this by changing to unique_ptr or adding a real deleter. Doing so will cause heap corruption on shutdown.
See also
docs/DESIGN_DECISIONS.md#intentional-leak-pattern

Definition at line 220 of file thread_integration.h.

Referenced by get_metrics(), get_thread_pool(), set_thread_pool(), submit_delayed_task(), and submit_task().


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