Files
fs2open.github.com/code/scripting/api/LuaCoroutineRunner.h
T
asarium ebcf686cf7 Add Lua API for promises and async coroutines
This adds a Lua API for representing asynchronous operations and running
coroutines based on those operations comfortably. This is very similar
to features other languages have introduced such as C# or JavaScript. In
fact, the whole "promise" thing is derived from how JavaScript
represents these operations.

This is the initial and very basic system for supporting async
coroutines in Lua. There is no native support for running these
operations at specific points (they run whenever the awaited promise
resolved) or making sure they do not leak through different game states.
2020-05-24 12:36:01 +02:00

23 lines
621 B
C++

#pragma once
#include "LuaPromise.h"
#include "scripting/lua/LuaThread.h"
namespace scripting {
namespace api {
/**
* @brief Runs an asynchronous Lua thread and runs it to completion
*
* This takes the specified lua thread and resumes it until it is completed. Every yielded value must be a LuaPromise
* which suspends the coroutine until that promise resolves.
*
* @param luaThread The lua coroutine to run
* @return A LuaPromise that will resolve with the value returned when the coroutine completes
*/
LuaPromise runAsyncCoroutine(luacpp::LuaThread luaThread);
} // namespace api
} // namespace scripting