File: LuaCoroutineRunner.h

package info (click to toggle)
freespace2 24.0.2%2Brepack-1
  • links: PTS, VCS
  • area: non-free
  • in suites: trixie
  • size: 43,188 kB
  • sloc: cpp: 583,107; ansic: 21,729; python: 1,174; sh: 464; makefile: 248; xml: 181
file content (29 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include "LuaPromise.h"

#include "executor/Executor.h"
#include "executor/IExecutionContext.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
 * @param executor The executor on which the code of the coroutine should be executed. May be nullptr.
 * @param executionContext The context to use for execution. Code on the coroutine will only be executed when the
 * context is valid.
 * @return A LuaPromise that will resolve with the value returned when the coroutine completes
 */
LuaPromise runAsyncCoroutine(luacpp::LuaThread luaThread,
	std::shared_ptr<executor::Executor> executor,
	std::shared_ptr<executor::IExecutionContext> executionContext);

} // namespace api
} // namespace scripting