AsyncAdvance Class Reference

#include <Pt/Lua/Script.h>

Awaitable advance of a Lua script. More...

Inherits Awaiter, and Connectable.

Public Member Functions

 AsyncAdvance (Script &script)
 Creates an awaitable for one advance of script.
 ~AsyncAdvance ()
 Cancels a pending step and detaches from the script.
Script::Status await_resume ()
 Returns the status of the completed advance step.
bool await_ready () const
 Returns false so co_await always suspends.
template<typename P>
bool await_suspend (std::coroutine_handle< P > h)
 Starts the operation and suspends the coroutine.
void cancel () override
 Cancels the in-flight operation.

Protected Member Functions

void setReady ()
 Resumes the waiting coroutine.

Detailed Description

AsyncAdvance is the C++20 form of beginAdvance(), endAdvance(), and advanced(). co_await script.advanceAsync() runs one step and await_resume() returns that step's Status. Continue awaiting while the status is Yield or NativeCall.

Only one awaiter may be pending on a script. A second construction throws std::logic_error. Destroying a pending awaiter cancels the script. Destroying the script detaches the awaiter.

Constructor & Destructor Documentation

◆ AsyncAdvance()

AsyncAdvance ( Script & script)
Exceptions
%std::logic_errorif another awaiter is already pending.

Member Function Documentation

◆ setReady()

void setReady ( )
protectedinherited

Call this when the asynchronous operation has completed. Typically connect a completion signal to this method.