Template Struct IntegrationTask

Nested Relationships

Nested Types

Struct Documentation

template<typename State>
struct IntegrationTask

C++20 协程与 diffeq 库集成示例

这个示例展示了如何使用 C++20 协程特性与微分方程积分器结合, 实现更细粒度的 CPU 运行控制和任务调度。

主要特性:

  • 协程化的积分步进,可以暂停和恢复

  • 细粒度的进度报告和控制

  • 协作式多任务处理

  • 零拷贝的状态传递

积分任务的协程返回类型

Public Types

using handle_type = std::coroutine_handle<promise_type>

Public Functions

inline explicit IntegrationTask(handle_type h)
inline ~IntegrationTask()
inline IntegrationTask(IntegrationTask &&other) noexcept
inline IntegrationTask &operator=(IntegrationTask &&other) noexcept
IntegrationTask(const IntegrationTask&) = delete
IntegrationTask &operator=(const IntegrationTask&) = delete
inline bool resume()
inline bool done() const
inline std::pair<State, double> get_current() const
inline void check_exception()
inline bool await_ready() const noexcept
inline void await_suspend(std::coroutine_handle<> h)
inline std::pair<State, double> await_resume()

Public Members

handle_type coro
struct promise_type

Public Functions

inline IntegrationTask get_return_object()
inline std::suspend_always initial_suspend()
inline std::suspend_always final_suspend() noexcept
inline void unhandled_exception()
inline void return_void()
inline std::suspend_always yield_value(std::pair<const State&, double> value)

Public Members

State current_state
double current_time = {0.0}
std::exception_ptr exception