开发者

Can you dump a running Lua coroutine to a file for a later resume?

While thinking of load/save mechanics for a game using Lua coroutines a quite interesting question has arisen -- can you dump a running Lua state to file co开发者_C百科mpletely? Apart from the obvious solutions of dumping the environment two notable problems have arisen -- dumping functions (which I think is easier), and dumping coroutines.

The latter made me wonder, whether it is possible at all to dump a running coroutine for a later resume call. The uses for that would be quite wide -- in the long run it would allow serialization of running tasks and passing them around Erlang style.

Hence the question -- is it possible?

I'm not searching for the (maybe obvious) "no" answer, for it probably is possible at some degree of work required (ergo in the worst case one could try to hack the compiler). I'm interested in how hard it would be...


The PlutoLibrary provides "heavy duty persistence" for Lua. It can serialize and deserialize coroutines.


There is an experimental module lper that can save and restore the state of the entire Lua interpreter. I've personally never played with it, as it depends on the Linux persistent memory library that has no obvious Windows counterpart. It probably would serve as a starting point for further research.

There is also a list of Lua persistence solutions in the wiki.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜