SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
Loading...
Searching...
No Matches
State.cpp
Go to the documentation of this file.
1#include "State.h"
2#include "SLLooper.h"
3
4namespace swt {
5
6// Specialization implementations for State<std::monostate>
7void State<std::monostate>::setValue(std::monostate &&value) {
8 m_value = std::move(value);
9 if (m_continuation && m_looper) {
10 executeContination(std::move(*m_value));
11 } else {
12 // std::cout << "m_continuation or m_looper is empty\n";
13 }
14}
15
16void State<std::monostate>::setException(std::exception_ptr exception) {
17 m_exception = exception;
18 if (m_errorHandler && m_errorLooper) {
19 executeErrorHandler(m_exception);
20 } else {
21 std::cout << "m_errorHandler or m_errorLooper is empty\n";
22 }
23}
24
25void State<std::monostate>::executeContination(std::monostate value) {
26 if (m_looper && m_continuation) {
27 m_looper->post([continuation = m_continuation]() mutable {
28 continuation();
29 });
30 }
31}
32
33void State<std::monostate>::executeErrorHandler(std::exception_ptr exception) {
34 if (m_errorLooper && m_errorHandler) {
35 m_errorLooper->post([errorHandler = m_errorHandler, exception]() mutable {
36 errorHandler(exception);
37 });
38 }
39}
40
41} // namespace swt
Main event loop coordinator for asynchronous task management and timer operations.
Promise/Future state management with template specialization for void types.
Thread-safe promise state management with continuation support.
Definition State.h:70
void setValue(tValue &&value)
Set the promise value and trigger continuation.
void setException(std::exception_ptr exception)
Set exception state and trigger error handler.
Software Timer namespace containing all timer-related classes.
Definition Awaitable.h:21