lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I've created a new patch that makes the Lua VM fully resumable. This
solves most of the practical problems with coroutines still present
in Lua 5.1-work4.

In short, you can now:
- Yield across all metamethods (except __gc).
- Yield across iterator functions (for x in func).
- Yield across callbacks (table.foreach(), dofile(), ...).
- Yield across protected callbacks (pcall(), xpcall(), ...).
- Yield from C functions and resume back to them.

This is a new and _fully portable_ approach to this problem. It combines
ideas from Eric Jacobs 'improved coroutines' patch and experiences gained
from working on my 'true C coroutines' patch. The changes to the Lua core
are as little intrusive as possible, owing to a flexible yield mechanism.

One side-effect is a faster pcall() and a slightly faster Lua VM in general.

You can read about all the gory details on the Wiki:

There are download links for the patch itself and for a patched-up
Lua 5.1-work4 distribution.

Please try it out and share your experiences. Any and all comments are
welcome (please send your comments to the mailing list since the Wiki
is not well suited to discussions). Thank you!