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

Specialization for void return type. More...

#include <Awaitable.h>

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

Public Member Functions

template<typename Func >
 WorkAwaitable (std::shared_ptr< SLLooper > looper, Func &&func)
 Construct WorkAwaitable with void function.
 
bool await_ready () const noexcept
 Check if work is ready (coroutine interface)
 
void await_suspend (std::coroutine_handle<> handle) const noexcept
 Suspend coroutine and execute work on background thread.
 
void await_resume () const
 Resume coroutine after void work completion.
 
std::shared_ptr< SLLoopergetLooper () const
 Get the SLLooper instance.
 
std::function< void()> getFunc () const
 Get the work function.
 
void setResult () const
 Mark work 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 WorkAwaitable for functions that return void. Avoids std::optional<void> compilation issues.

co_await looper->awaitWork([]() -> void {
// Side-effect work on background thread
std::cout << "Background work completed" << std::endl;
});

Definition at line 131 of file Awaitable.h.

Constructor & Destructor Documentation

◆ WorkAwaitable()

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

Construct WorkAwaitable with void function.

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

Definition at line 146 of file Awaitable.h.

Member Function Documentation

◆ await_ready()

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

Check if work is ready (coroutine interface)

Returns
false - always suspend initially

Definition at line 153 of file Awaitable.h.

◆ await_resume()

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

Resume coroutine after void work completion.

Exceptions
std::exceptionif work failed

Definition at line 165 of file Awaitable.h.

◆ await_suspend()

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

Suspend coroutine and execute work on background thread.

Parameters
handleCoroutine handle for resumption

Definition at line 281 of file SLLooper.cpp.

References SLLOOPER_DEBUG, SLLOOPER_ERROR, and SLLOOPER_ERROR_STREAM.

◆ getFunc()

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

Get the work function.

Returns
Void function to execute

Definition at line 180 of file Awaitable.h.

◆ getLooper()

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

Get the SLLooper instance.

Returns
Shared pointer to looper

Definition at line 174 of file Awaitable.h.

◆ setException()

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

Set exception result (internal use)

Parameters
exException pointer from work function

Definition at line 191 of file Awaitable.h.

◆ setResult()

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

Mark work as completed (internal use)

Definition at line 185 of file Awaitable.h.


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