开发者

Should lua_resume always have a balancing lua_yield?

I have a C-based API exposed to lua that schedules lua coroutines based on triggers in the game engine.

I have been multitasking lua in my gameloop using synchronous threads (fibers) to maintain a pool of lua_Thread objects that I only ever call lua_resume on.

Rereading the lua_resume/lua_yield documentation implies I should be looking at a large memory leak, as each call to lua_yield must be able to pop state information off some kind 开发者_开发技巧of stack?


Coroutines are properly collected by GC. (if there are no references to it-it will be collected. So there is no chance of memory leaks.) You don't have to yield(), you can allow the coroutine to finish, or return from it - you wont be able to resume a finished coroutine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜