SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
|
Template specialization for void-returning promises. More...
#include <Promise.h>
Public Member Functions | |
Promise () | |
Default constructor for void promise. | |
void | set_value () |
Mark void promise as completed. | |
void | set_exception (std::exception_ptr exception) |
Reject void promise with an exception. | |
template<typename F > | |
auto | then (std::shared_ptr< SLLooper > &looper_, F func) -> Promise< std::invoke_result_t< F > > |
Chain continuation callback for void promise completion. | |
template<typename F > | |
auto | catchError (std::shared_ptr< SLLooper > &looper_, F func) -> Promise< void > |
Chain error handler for void promise rejection. | |
void | operator() () |
Function call operator for convenient void promise resolution. | |
Template specialization for void-returning promises.
This specialization handles promises that represent completion of operations without returning values. Uses std::monostate internally to represent the "no value" state while maintaining the same API as value-returning promises.
Key differences from general template:
swt::Promise< void >::Promise | ( | ) |
Default constructor for void promise.
Creates a void promise using State<std::monostate> for internal state management while providing a clean void interface.
Definition at line 7 of file Promise.cpp.
auto swt::Promise< void >::catchError | ( | std::shared_ptr< SLLooper > & | looper_, |
F | func | ||
) | -> Promise< void > |
Chain error handler for void promise rejection.
F | Function type for error handler callback (auto-deduced) |
looper_ | SLLooper instance for callback execution |
func | Error handler function that receives std::exception_ptr |
Registers an error handler for void promise rejection. If the error handler executes successfully (without throwing), the promise chain continues with success state.
|
inline |
Function call operator for convenient void promise resolution.
Convenience operator that allows using the void promise as a callable object for completion marking. Equivalent to calling set_value().
Definition at line 355 of file Promise.h.
References swt::Promise< tValue >::set_value().
void swt::Promise< void >::set_exception | ( | std::exception_ptr | exception | ) |
Reject void promise with an exception.
exception | Exception pointer to reject the promise with |
Identical behavior to general template - sets promise to failed state and triggers error handlers.
Definition at line 13 of file Promise.cpp.
void swt::Promise< void >::set_value | ( | ) |
Mark void promise as completed.
Resolves the void promise by marking it as completed and triggering any registered continuation callbacks. No value is provided since this represents operation completion.
Definition at line 9 of file Promise.cpp.
auto swt::Promise< void >::then | ( | std::shared_ptr< SLLooper > & | looper_, |
F | func | ||
) | -> Promise< std::invoke_result_t< F > > |
Chain continuation callback for void promise completion.
F | Function type for continuation callback (auto-deduced) |
looper_ | SLLooper instance for callback execution |
func | Continuation function (takes no parameters) |
Registers a continuation callback that executes when the void promise completes. The continuation function takes no parameters since void promises don't produce values, but can return any type.