38 Event(std::coroutine_handle<promise_type> h);
102 [[nodiscard]]
virtual bool is_active()
const;
106 [[nodiscard]]
bool done()
const;
108 [[nodiscard]] std::coroutine_handle<promise_type> get_handle()
const;
116 return m_handle.promise().should_terminate;
125 m_handle.promise().should_terminate = should_terminate;
140 template <
typename... Args>
143 update_params_impl(std::forward<Args>(args)...);
155 template <
typename T>
158 set_state_impl(key, std::move(value));
170 template <
typename T>
173 return get_state_impl<T>(key);
177 virtual void set_state_impl(
const std::string& key, std::any value);
179 virtual void* get_state_impl_raw(
const std::string& key);
186 template <
typename T>
189 void* raw_ptr = get_state_impl_raw(key);
194 return std::any_cast<T>(
static_cast<std::any*
>(raw_ptr));
195 }
catch (
const std::bad_any_cast&) {
215 template <
typename T,
typename... Args>
218 set_state(key, std::move(value));
219 if constexpr (
sizeof...(args) > 0) {
220 update_params_impl(std::forward<Args>(args)...);
T * get_state_impl(const std::string &key)
Implementation helper for get_state.
void set_state(const std::string &key, T value)
Sets a named state value in the coroutine.
std::coroutine_handle< promise_type > m_handle
virtual void set_should_terminate(bool should_terminate)
Set should_terminate flag in promise.
virtual bool get_should_terminate() const
Get should_terminate flag from promise.
void update_params_impl(const std::string &key, T value, Args... args)
Implementation helper for update_params.
T * get_state(const std::string &key)
Gets a named state value from the coroutine.
void update_params(Args... args)
Updates multiple named parameters in the coroutine's state.
virtual void update_params_impl()
brief Implementation helper for update_params
Coroutine type for event-driven suspension.