lua-users home
lua-l archive

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


Steve,

I always use a separate thread for LUA Execution under Windows.  This isolates your GUI message processing loop from the script - which, at the very least, should make your program more responsive.

Then you can also monitor that thread and kill it if it seems to have run amok.

I have taken to using part of Muscle (http://www.lcscanada.com/muscle/) to build a flexible, tagged message passing system to pass info (via queues) to various threads.

If you want more info let me know.

Hope this helps.
Terry 


On Wed, 14 Jul 2004 21:00:16 +0100, Stephen Page wrote:
> Hello everyone,
>
>
> I have a question, I apologise if it's been dealt with before, but
> I would appreciate some advice on the best way forward.
>
> I'm embedding Lua in my event driven GUI application, to allow
> users to enters small scripts which are called under certain
> conditions, for example from a button click event. The intended
> users will not be programmers by profession. I will sandbox the
> environment.
>
> But, I'm worried they will enter Lua code that will hang my
> application, for example running an infinite loop.
>
> So I'd like to execute user Lua, but with rather more control than
> just passing execution over to lua_pcall(). I want to give the user
> the option to cleanly abort the execution of a running script.
>
> I suspect I can use the Debug library in some way to achieve this,
> but does anyone have any specific clues ?
>
> Is it best to just invoke the Lua execution in another thread so as
> not to hold the GUI event loop, and somehow kill that thread later
> if it's thought the script has gone rogue ? Is there a hook in the
> Lua VM to allow me to terminate it cleanly ?
>
> I'm sure when embedding Lua this has been an issue that people have
> overcome before, what's the preferred way to solve it ?
>
> Thanks in advance, Steve