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::DelayAwaitable Class Reference

Awaitable for delay operations. More...

#include <Awaitable.h>

Collaboration diagram for swt::DelayAwaitable:
Collaboration graph

Public Member Functions

 DelayAwaitable (std::shared_ptr< SLLooper > looper, int delayMs)
 Construct DelayAwaitable with delay duration.
 
bool await_ready () const noexcept
 Check if delay is ready (coroutine interface)
 
void await_suspend (std::coroutine_handle<> handle) const noexcept
 Suspend coroutine and start timer.
 
void await_resume () const noexcept
 Resume coroutine after delay (no return value)
 
int getDelayMs () const
 Get delay duration.
 
std::shared_ptr< SLLoopergetLooper () const
 Get the SLLooper instance.
 
void setReady () const
 Mark delay as completed (internal use)
 

Detailed Description

Awaitable for delay operations.

Provides coroutine-based delay functionality using SLLooper's timer system. Suspends the coroutine for a specified duration.

co_await looper->awaitDelay(1000); // Wait 1 second

Definition at line 208 of file Awaitable.h.

Constructor & Destructor Documentation

◆ DelayAwaitable()

swt::DelayAwaitable::DelayAwaitable ( std::shared_ptr< SLLooper looper,
int  delayMs 
)
inline

Construct DelayAwaitable with delay duration.

Parameters
looperShared pointer to SLLooper
delayMsDelay duration in milliseconds

Definition at line 220 of file Awaitable.h.

Member Function Documentation

◆ await_ready()

bool swt::DelayAwaitable::await_ready ( ) const
inlinenoexcept

Check if delay is ready (coroutine interface)

Returns
false - always suspend initially

Definition at line 227 of file Awaitable.h.

◆ await_resume()

void swt::DelayAwaitable::await_resume ( ) const
inlinenoexcept

Resume coroutine after delay (no return value)

Definition at line 238 of file Awaitable.h.

◆ await_suspend()

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

Suspend coroutine and start timer.

Parameters
handleCoroutine handle for resumption

Definition at line 246 of file SLLooper.cpp.

References SLLOOPER_DEBUG, and SLLOOPER_DEBUG_STREAM.

◆ getDelayMs()

int swt::DelayAwaitable::getDelayMs ( ) const
inline

Get delay duration.

Returns
Delay in milliseconds

Definition at line 244 of file Awaitable.h.

◆ getLooper()

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

Get the SLLooper instance.

Returns
Shared pointer to looper

Definition at line 250 of file Awaitable.h.

◆ setReady()

void swt::DelayAwaitable::setReady ( ) const
inline

Mark delay as completed (internal use)

Definition at line 255 of file Awaitable.h.


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