add app.is_instance_alive & rename app.terminate to app.terminate_instance

This commit is contained in:
MihailRis 2026-08-02 18:32:54 +03:00
parent 466f515ea9
commit 6bbc78098d
3 changed files with 19 additions and 3 deletions

View file

@ -204,6 +204,9 @@ app.start_background_instance(
output_file: string | nil output_file: string | nil
) -> int ) -> int
-- Checks if the engine sub-instance is alive.
app.is_instance_alive(handle: int) -> boolean
-- Stops the engine sub-instance. -- Stops the engine sub-instance.
-- Returns true if the instance was alive at the time of the call. -- Returns true if the instance was alive at the time of the call.
app.terminate(handle: int) -> boolean app.terminate(handle: int) -> boolean

View file

@ -156,7 +156,10 @@ app.start_background_instance(
output_file: string | nil output_file: string | nil
) -> int ) -> int
-- Проверяет, жив ли под-экземпляр движка.
app.is_instance_alive(handle: int) -> boolean
-- Останавливает под-экземпляр движка. -- Останавливает под-экземпляр движка.
-- Возвращает true если экземпляр был жив в момент вызова. -- Возвращает true если экземпляр был жив в момент вызова.
app.terminate(handle: int) -> boolean app.terminate_instance(handle: int) -> boolean
``` ```

View file

@ -425,7 +425,16 @@ static int l_start_background_instance(lua::State* L) {
return lua::pushinteger(L, handle); return lua::pushinteger(L, handle);
} }
static int l_terminate(lua::State* L) { static int l_is_instance_alive(lua::State* L) {
int handle = lua::tointeger(L, 1);
if (handle < 0 || handle >= ::processes.size()) {
throw std::runtime_error("invalid process handle");
}
auto& process = ::processes[handle];
return lua::pushboolean(L, process && process->isActive());
}
static int l_terminate_instance(lua::State* L) {
int handle = lua::tointeger(L, 1); int handle = lua::tointeger(L, 1);
if (handle < 0 || handle >= ::processes.size()) { if (handle < 0 || handle >= ::processes.size()) {
throw std::runtime_error("invalid process handle"); throw std::runtime_error("invalid process handle");
@ -472,6 +481,7 @@ const luaL_Reg applib[] = {
{"create_memory_device", lua::wrap<l_create_memory_device>}, {"create_memory_device", lua::wrap<l_create_memory_device>},
{"start_debug_instance", lua::wrap<l_start_debug_instance>}, {"start_debug_instance", lua::wrap<l_start_debug_instance>},
{"start_background_instance", lua::wrap<l_start_background_instance>}, {"start_background_instance", lua::wrap<l_start_background_instance>},
{"terminate", lua::wrap<l_terminate>}, {"is_instance_alive", lua::wrap<l_is_instance_alive>},
{"terminate_instance", lua::wrap<l_terminate_instance>},
{nullptr, nullptr} {nullptr, nullptr}
}; };