lua-users home
lua-l archive

Re: executing functions from file, without using luaL_dofile

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


To clarify, i have a Lua script which look like this:
-- main lua script
require "dll.so"
function computing()
 --this function is launched in a thread
end
repeat
 dll:launch_computing(computing) --the 2nd thread
 local is_quitting = dll:redraw() -- main thread
until (is_quitting)
As Lua is not reentrant, i cannot call the "computing()" function straight from the DLL. Then, i've created an new lua_State in the DLL, and i use it for reloading the whole lua script above.
(i get the script name with arg[0] from the "main" Lua state)
But if i execute the script after reloading it, it will call again and again the thread creation (rapid stack overflow). I know that you're thinking it would be easier to store "computing" function in another script file, anyway i cannot access global variables from main Lua script. That's what i'm going to do. I was asking about "on demand" function compilation just out of curiosity.

AltStyle によって変換されたページ (->オリジナル) /