[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_newthread/lua_resetthread without eating stack possible?
- From: Francisco Olarte <folarte@...>
- Date: Mon, 14 Jun 2021 18:59:49 +0200
On Mon, Jun 14, 2021 at 5:49 PM Flyer31 Test <firstname.lastname@example.org> wrote:
> Thank you, so only one miracuolous line more after each reset_thread:
> lua_pop( LuaBase, 1)
You're welcome. Remember stack balance is important, you must pay
attention to the little numbers at the right of each function
description ( they are described in 4.6 in the 5.4 manual "Each
function has an indicator like this: [-o, +p, x] The first field, o,
is how many elements the function pops from the stack. The second
field, p, is how many elements the function pushes onto the stack. ".
> ... and now really thread world looks nice so far... thank you... (i tested it, it seems to work perfect now as far as I can see it... at least LuaBase->top keeps stable now, also for 10000 such thread invocations and killings... and my STM32G4 ARM-CortexM4 system with quite limited stack and heap for sure would pinch me in case of ANY problems) .
If you have a long chain of operations and you do not want to keep
track of the stack, or it is difficult, you can also justo save
lua_gettop() at thre start, do lua_checkstack whenever you need to
insure room and a lua_settop() at the the end, but in long operations
( like your loop ) you need to be careful with stack balance.