3

我希望能够将 libtask 协程挂起到磁盘,然后在不同的进程下再次恢复它们,这样它们就可以从中断的地方继续。

4

1 回答 1

2

This is not possible. Coroutine state is tied to the running process's execution state, open file descriptors, etc. It's actually a very difficult problem to solve in the general case, see this page on Wikipedia for a discussion:

http://en.wikipedia.org/wiki/Application_checkpointing

The approach you could take is to carefully define your coroutine's state and determine what information you'd need to store in order to reconstruct it. Then, you'd make the coroutine able to resume given that information.

Dragonfly BSD has the ability to suspend tasks and later resume them, but that's the only general solution I've heard of, save for VM image-based systems like Smalltalk and Squeak.

于 2013-06-29T02:01:14.003 回答