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
swt::PostAwaitable< void > Class Reference

Specialization for void return type. More...

#include <Awaitable.h>

Collaboration diagram for swt::PostAwaitable< void >:
Collaboration graph

Public Member Functions

template<typename Func >
 PostAwaitable (std::shared_ptr< SLLooper > looper, Func &&func)
 Construct PostAwaitable with void function.
 
bool await_ready () const noexcept
 Check if operation is ready (coroutine interface)
 
void await_suspend (std::coroutine_handle<> handle) const noexcept
 Suspend coroutine and post to main thread.
 
void await_resume () const
 Resume coroutine after void operation completion.
 
std::function< void()> getFunc () const
 Get the main thread function.
 
std::shared_ptr< SLLoopergetLooper () const
 Get the SLLooper instance.
 
void setResult () const
 Mark operation as completed (internal use)
 
void setException (std::exception_ptr ex) const
 Set exception result (internal use)
 

Detailed Description

Specialization for void return type.

Specialized version of PostAwaitable for functions that return void. Executes side-effect operations on the main thread.

co_await looper->awaitPost([]() -> void {
// UI update or thread-safe operation
std::cout << "Main thread operation completed" << std::endl;
});

Definition at line 363 of file Awaitable.h.

Constructor & Destructor Documentation

◆ PostAwaitable()

template<typename Func >
swt::PostAwaitable< void >::PostAwaitable ( std::shared_ptr< SLLooper looper,
Func &&  func 
)
inline

Construct PostAwaitable with void function.

Template Parameters
FuncFunction type (auto-deduced)
Parameters
looperShared pointer to SLLooper
funcVoid function to execute on main thread

Definition at line 378 of file Awaitable.h.

Member Function Documentation

◆ await_ready()

bool swt::PostAwaitable< void >::await_ready ( ) const
inlinenoexcept

Check if operation is ready (coroutine interface)

Returns
false - always suspend initially

Definition at line 385 of file Awaitable.h.

◆ await_resume()

void swt::PostAwaitable< void >::await_resume ( ) const
inline

Resume coroutine after void operation completion.

Exceptions
std::exceptionif operation failed

Definition at line 397 of file Awaitable.h.

◆ await_suspend()

void swt::PostAwaitable< void >::await_suspend ( std::coroutine_handle<>  handle) const
noexcept

Suspend coroutine and post to main thread.

Parameters
handleCoroutine handle for resumption

Definition at line 326 of file SLLooper.cpp.

References SLLOOPER_DEBUG, SLLOOPER_ERROR, and SLLOOPER_ERROR_STREAM.

◆ getFunc()

std::function< void()> swt::PostAwaitable< void >::getFunc ( ) const
inline

Get the main thread function.

Returns
Void function to execute

Definition at line 405 of file Awaitable.h.

◆ getLooper()

std::shared_ptr< SLLooper > swt::PostAwaitable< void >::getLooper ( ) const
inline

Get the SLLooper instance.

Returns
Shared pointer to looper

Definition at line 411 of file Awaitable.h.

◆ setException()

void swt::PostAwaitable< void >::setException ( std::exception_ptr  ex) const
inline

Set exception result (internal use)

Parameters
exException pointer from main thread function

Definition at line 422 of file Awaitable.h.

◆ setResult()

void swt::PostAwaitable< void >::setResult ( ) const
inline

Mark operation as completed (internal use)

Definition at line 416 of file Awaitable.h.


The documentation for this class was generated from the following files: