Forcing a Lua script to exit

后端 未结 10 1028
长情又很酷
长情又很酷 2020-12-23 18:49

How do you end a long running Lua script?

I have two threads, one runs the main program and the other controls a user supplied Lua script. I need to kill the thread

10条回答
  •  孤城傲影
    2020-12-23 18:59

    You might wanna take look at https://github.com/amilamad/preemptive-task-scheduler-for-lua project. its preemptive scheduler for lua. It uses a lua_yeild function inside the hook. So you can suspend your lua thread. It also uses longjmp inside but its is much safer.

提交回复
热议问题