DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
diffeq::core::composable::TimeoutDecorator< S > Class Template Reference

Timeout decorator - adds timeout protection to any integrator. More...

#include <timeout_decorator.hpp>

Inheritance diagram for diffeq::core::composable::TimeoutDecorator< S >:
Collaboration diagram for diffeq::core::composable::TimeoutDecorator< S >:

Public Member Functions

 TimeoutDecorator (std::unique_ptr< AbstractIntegrator< S > > integrator, TimeoutConfig config={})
 Construct timeout decorator.
 
TimeoutResult integrate_with_timeout (typename IntegratorDecorator< S >::state_type &state, typename IntegratorDecorator< S >::time_type dt, typename IntegratorDecorator< S >::time_type end_time)
 Main timeout-protected integration method.
 
void integrate (typename IntegratorDecorator< S >::state_type &state, typename IntegratorDecorator< S >::time_type dt, typename IntegratorDecorator< S >::time_type end_time) override
 Override standard integrate to use timeout protection.
 
TimeoutConfigconfig ()
 Access and modify timeout configuration.
 
const TimeoutConfigconfig () const
 
void update_config (TimeoutConfig new_config)
 Update timeout configuration with validation.
 
- Public Member Functions inherited from diffeq::core::composable::IntegratorDecorator< S >
 IntegratorDecorator (std::unique_ptr< base_type > integrator)
 Construct decorator wrapping another integrator.
 
virtual ~IntegratorDecorator ()=default
 Virtual destructor for proper cleanup.
 
void step (state_type &state, time_type dt) override
 
void integrate (state_type &state, time_type dt, time_type end_time) override
 
time_type current_time () const override
 
void set_time (time_type t) override
 
void set_system (system_function sys) override
 
base_typewrapped ()
 Access to wrapped integrator for advanced use.
 
const base_typewrapped () const
 
bool has_wrapped_integrator () const
 Check if wrapped integrator exists.
 
- Public Member Functions inherited from diffeq::core::AbstractIntegrator< S >
 AbstractIntegrator (system_function sys)
 
time_type current_time () const
 
void set_time (time_type t)
 
void set_system (system_function sys)
 

Additional Inherited Members

- Public Types inherited from diffeq::core::composable::IntegratorDecorator< S >
using base_type = AbstractIntegrator< S >
 
using state_type = typename base_type::state_type
 
using time_type = typename base_type::time_type
 
using system_function = typename base_type::system_function
 
- Public Types inherited from diffeq::core::AbstractIntegrator< S >
using state_type = S
 
using time_type = typename S::value_type
 
using value_type = typename S::value_type
 
using system_function = std::function< void(time_type, const state_type &, state_type &)>
 
- Protected Member Functions inherited from diffeq::core::AbstractIntegrator< S >
void advance_time (time_type dt)
 
- Protected Attributes inherited from diffeq::core::composable::IntegratorDecorator< S >
std::unique_ptr< base_typewrapped_integrator_
 
- Protected Attributes inherited from diffeq::core::AbstractIntegrator< S >
system_function sys_
 
time_type current_time_
 

Detailed Description

template<system_state S>
class diffeq::core::composable::TimeoutDecorator< S >

Timeout decorator - adds timeout protection to any integrator.

This decorator provides robust timeout protection with the following features:

  • Configurable timeout duration with validation
  • Optional progress monitoring with user cancellation
  • Comprehensive error handling and reporting
  • Thread-safe async execution with proper cleanup

Key Design Principles:

  • Single Responsibility: ONLY handles timeout protection
  • No Dependencies: Works with any integrator type
  • Robust Error Handling: Graceful failure modes
  • User Control: Progress callbacks and cancellation support

Definition at line 100 of file timeout_decorator.hpp.

Constructor & Destructor Documentation

◆ TimeoutDecorator()

template<system_state S>
diffeq::core::composable::TimeoutDecorator< S >::TimeoutDecorator ( std::unique_ptr< AbstractIntegrator< S > >  integrator,
TimeoutConfig  config = {} 
)
inlineexplicit

Construct timeout decorator.

Parameters
integratorThe integrator to wrap
configTimeout configuration (validated on construction)
Exceptions
std::invalid_argumentif config is invalid

Definition at line 111 of file timeout_decorator.hpp.

Member Function Documentation

◆ config() [1/2]

Access and modify timeout configuration.

Definition at line 170 of file timeout_decorator.hpp.

◆ config() [2/2]

template<system_state S>
const TimeoutConfig & diffeq::core::composable::TimeoutDecorator< S >::config ( ) const
inline

Definition at line 171 of file timeout_decorator.hpp.

◆ integrate()

template<system_state S>
void diffeq::core::composable::TimeoutDecorator< S >::integrate ( typename IntegratorDecorator< S >::state_type &  state,
typename IntegratorDecorator< S >::time_type  dt,
typename IntegratorDecorator< S >::time_type  end_time 
)
inlineoverride

Override standard integrate to use timeout protection.

Definition at line 158 of file timeout_decorator.hpp.

Here is the call graph for this function:

◆ integrate_with_timeout()

template<system_state S>
TimeoutResult diffeq::core::composable::TimeoutDecorator< S >::integrate_with_timeout ( typename IntegratorDecorator< S >::state_type &  state,
typename IntegratorDecorator< S >::time_type  dt,
typename IntegratorDecorator< S >::time_type  end_time 
)
inline

Main timeout-protected integration method.

Parameters
stateInitial state (modified in-place)
dtTime step
end_timeFinal integration time
Returns
Detailed result with timing and status information

Definition at line 124 of file timeout_decorator.hpp.

Here is the caller graph for this function:

◆ update_config()

template<system_state S>
void diffeq::core::composable::TimeoutDecorator< S >::update_config ( TimeoutConfig  new_config)
inline

Update timeout configuration with validation.

Parameters
new_configNew configuration
Exceptions
std::invalid_argumentif new config is invalid

Definition at line 178 of file timeout_decorator.hpp.

Here is the call graph for this function:

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