|
SW Task Event Loop Framework v1.0.0
High-performance C++ asynchronous event loop framework with timer management and promise-based programming
|
Awaitable for executing function on main thread. More...
#include <Awaitable.h>

Public Member Functions | |
| template<typename Func > | |
| PostAwaitable (std::shared_ptr< SLLooper > looper, Func &&func) | |
| Construct PostAwaitable with function. | |
| bool | await_ready () const noexcept |
| Check if result is ready (coroutine interface) | |
| void | await_suspend (std::coroutine_handle<> handle) const noexcept |
| Suspend coroutine and post to main thread. | |
| auto | await_resume () const -> T |
| Resume coroutine and return result. | |
| std::function< T()> | getFunc () const |
| Get the main thread function. | |
| std::shared_ptr< SLLooper > | getLooper () const |
| Get the SLLooper instance. | |
| void | setResult (T result) const |
| Set successful result (internal use) | |
| void | setException (std::exception_ptr ex) const |
| Set exception result (internal use) | |
Awaitable for executing function on main thread.
| T | Return type of the main thread function |
PostAwaitable executes a function on the main event loop thread and suspends the coroutine until completion. Useful for UI updates or thread-safe operations.
Definition at line 275 of file Awaitable.h.
|
inline |
Construct PostAwaitable with function.
| Func | Function type (auto-deduced) |
| looper | Shared pointer to SLLooper |
| func | Function to execute on main thread |
Definition at line 291 of file Awaitable.h.
|
inlinenoexcept |
Check if result is ready (coroutine interface)
Definition at line 298 of file Awaitable.h.
|
inline |
Resume coroutine and return result.
| std::exception | if function failed |
Definition at line 311 of file Awaitable.h.
|
noexcept |
Suspend coroutine and post to main thread.
| handle | Coroutine handle for resumption |
Definition at line 305 of file SLLooper.cpp.
References SLLOOPER_DEBUG, SLLOOPER_ERROR, and SLLOOPER_ERROR_STREAM.
|
inline |
Get the main thread function.
Definition at line 321 of file Awaitable.h.
|
inline |
Get the SLLooper instance.
Definition at line 327 of file Awaitable.h.
|
inline |
Set exception result (internal use)
| ex | Exception pointer from main thread function |
Definition at line 342 of file Awaitable.h.
|
inline |
Set successful result (internal use)
| result | Result value from main thread function |
Definition at line 333 of file Awaitable.h.