Commit [ade877] Maximize Restore History

Resume can now be asynchronous: If target coro is currently not

sleeping/suspended, resume value ('update' argument) is queued
so that target coro receives the update when it next calls sleep/suspend.
With this suspend/resume can be viewed as send/receive to exchange
messages (although, it may be better to use Python's deque etc., for
implementing producer/consumer instead). Accordingly, added aliases
for sleep and resume to receive and send.

Added support for hot swapping of generator function of coro. A coro
must first indicate that it is setup for hot swapping with the function
hot_swappable. hot_swappable can be used to toggle readiness, if necessary.
The function hot_swap can be used to replace current generator with new
generator. AsynCoro then sends HotSwap exception whenever a) coro currently
is ready for hot_swap (i.e., called hot_swappable with True), b) it is
currently executing at top-level (i.e., has not called other generator
functions) and c) not processing exceptions. The coro can inspect new
generator, if necessary, and can do any preparation for hot swapping,
e.g., saving state. Then it must re-raise the same exception, which causes
AsynCoro to replace the generator and starts executing it. Any resumes
queued in the previous generator are not reset, so new generator can
process pending/queued resumes.

pgiri pgiri 2012-05-08

changed Diff Switch to side-by-side view