lua-users home
lua-l archive

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


Andrew Teirney wrote:
>  i just want to be able to load
and execute a chunk with an infinite service loop, then jumping out of the lua land every ms or so that i can service some devices, and then go back to lua from where it left off.

Hi Andrew,

Just make these changes to my previous example. Have your RTI to set a flag every x miliseconds. Check the flag in the main loop of your Lua script, and then clear the flag and yield if the flag is set.

Cheers,

- Peter Shook

$ diff a.c b.c
30d29
<     lua_State *C = lua_newthread(L);
32c31
<     if (report(C, luaL_loadfile(C, argv[1]) )) exit(1);
---
>     if (report(L, luaL_loadfile(L, argv[1]) )) exit(1);
36c35
<       if (report(C, lua_resume(C, 0) )) exit(2);
---
>       if (report(L, lua_resume(L, 0) )) exit(2);