summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-07-10 15:17:58 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-07-10 15:17:58 -0400
commitb032abe2074949074c893153d992ae264c34116a (patch)
tree9b7c65188ab4abcb7aa6f022438d3b7885c9e834 /indra/newview
parent8c94ff566a4f9076607d1b988f3eb7ad7e200bd9 (diff)
parente26727e03bb02d26b3f0d83f748dbd8eb88e4940 (diff)
Merge branch 'lua-atexit-run' into lua-no-reuse.
We couldn't discard the "p.s." fiber.run() call from LuaState::expr() until we could count on fiber.lua's LL.atexit(fiber.run) call being executed after each Lua script or chunk, and we couldn't count on that until we made LLLUAmanager::runScriptFile() instantiate and destroy its LuaState on the C++ Lua-specific coroutine. Now that we've done that, use LL.atexit(fiber.run) instead of the whole special-case "p.s." in LuaState::expr().
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/scripts/lua/require/fiber.lua6
-rw-r--r--indra/newview/tests/llluamanager_test.cpp6
2 files changed, 12 insertions, 0 deletions
diff --git a/indra/newview/scripts/lua/require/fiber.lua b/indra/newview/scripts/lua/require/fiber.lua
index cae27b936b..b3c684dd67 100644
--- a/indra/newview/scripts/lua/require/fiber.lua
+++ b/indra/newview/scripts/lua/require/fiber.lua
@@ -337,4 +337,10 @@ function fiber.run()
return idle_done
end
+-- Make sure we finish up with a call to run(). That allows a consuming script
+-- to kick off some number of fibers, do some work on the main thread and then
+-- fall off the end of the script without explicitly calling fiber.run().
+-- run() ensures the rest of the fibers run to completion (or error).
+LL.atexit(fiber.run)
+
return fiber
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp
index 79ec9b9d3a..26a4ac95e3 100644
--- a/indra/newview/tests/llluamanager_test.cpp
+++ b/indra/newview/tests/llluamanager_test.cpp
@@ -413,6 +413,12 @@ namespace tut
"fiber.launch('catch_special', drain, catch_special)\n"
"fiber.launch('requester(a)', requester, 'a')\n"
"fiber.launch('requester(b)', requester, 'b')\n"
+ // A script can normally count on an implicit fiber.run() call
+ // because fiber.lua calls LL.atexit(fiber.run). But atexit()
+ // functions are called by ~LuaState(), which (in the code below)
+ // won't be called until *after* we expect to interact with the
+ // various fibers. So make an explicit call for test purposes.
+ "fiber.run()\n"
);
LLSD requests;