开发者

Setting timeout for embedded Lua

I have embedded Lua in a C/C+= application. I want to be able to set a timeout value to prevent getting trapped with badly written scripts that can result in infinite loops (or even string searches that take an infinite time to complete).

Basically, I want to be able to set a time interval and if the script fails to complete running at the end of that time interval, I want to be able to kill the Lua script engine (gracefully, if possible).

Anyone knows of best practise way to do开发者_运维技巧 this?


One way to control the amount of time a script takes is to set a count hook and then raise an error in the hook. But this does not work if the script can call C functions that may take a long time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜