9#include <Pt/System/Selectable.h>
17#if __cplusplus >= 202002L
19#include <Pt/Coroutine.h>
26namespace Reflex {
class Type; }
34#if __cplusplus >= 202002L
116 {
return _errorMsg; }
122#if __cplusplus >= 202002L
141#if __cplusplus >= 202002L
142 friend class AsyncAdvance;
144 void attachAwaiter(AsyncAdvance& awaiter);
146 void detachAwaiter(AsyncAdvance& awaiter);
153 void onAsyncCallFinished();
155 bool onAsyncCallReady();
157 int pushResult(
Pt::Any& value, Pt::Reflex::Type& type);
161 bool isCancelled()
const;
163 void setError(
const std::string& msg);
165 static void yieldHook(lua_State* L, lua_Debug* ar);
172 std::string _errorMsg;
179 #if __cplusplus >= 202002L
180 AsyncAdvance* _awaiter =
nullptr;
184#if __cplusplus >= 202002L
221 void onBegin()
override;
223 void onCancel()
override;
Value of any copyable type.
Definition Any.h:79
Provides the base class for I/O-driven co_await-able operations.
Definition Coroutine.h:126
Connection Management for Signal and Slot Objects.
Definition Connectable.h:50
Connectable()
Default constructor.
Awaitable advance of a Lua script.
Definition Script.h:202
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.
Asynchronous native call from Lua.
Definition AsyncCall.h:42
Synchronous native call from Lua.
Definition Call.h:38
Lua state with a bound type catalog.
Definition Context.h:53
Status advance()
Advances the script on the calling thread.
Script(Context &ctx, const char *script)
Loads script into ctx as a coroutine.
Status endAdvance() const
Returns the status of the last advance step.
void beginAdvance()
Starts an asynchronous advance step on the event loop.
static Script * fromState(lua_State *L)
Returns the script stored in the registry of L, or a null pointer.
void onCancel()
Blocks until operation has cancelled.
bool onRun()
Check if ready and run.
const std::string & errorMessage() const
Returns the last compile or runtime error text.
Definition Script.h:115
Status
Step reached by the last advance.
Definition Script.h:78
@ ScriptError
Compile or runtime failure.
Definition Script.h:82
@ NativeCall
A reflected or asynchronous native call is pending.
Definition Script.h:80
@ Yield
Cooperative pause of the Lua coroutine.
Definition Script.h:79
@ ScriptOk
The chunk finished.
Definition Script.h:81
~Script()
Cancels pending work and releases the context.
Pt::Signal & advanced()
Signal emitted when an asynchronous advance step completes.
void onDetach(Pt::System::EventLoop &loop)
Detached from loop.
AsyncAdvance advanceAsync()
Returns an awaitable for one asynchronous advance step.
void onAttach(Pt::System::EventLoop &loop)
Attached to loop.
Multicast Signal to call multiple slots.
Definition Signal.h:190
Event loop of a thread or process.
Definition EventLoop.h:83
Operation that runs through an event loop.
Definition Selectable.h:60
Lua runtime and reflected bindings.
Core module.
Definition Allocator.h:33