Coco — True C Coroutines for Lua (original) (raw)
Coco is a small extension to get True C Coroutinesemantics for Lua 5.1. Coco is available as a patch set against the standard Lua 5.1.5 source distribution.
Coco is also integrated into LuaJIT 1.xto allow yielding for JIT compiled functions. But note that Coco does not depend on LuaJIT and works fine with plain Lua.
Coco is Copyright © 2004-2016 Mike Pall. Coco is free software, released under theMIT license(same license as the Lua core).
Features
True C coroutine semantics mean you can yield from a coroutine across a C call boundary and resume back to it. Coco allows you to use a dedicated C stack for each coroutine. Resuming a coroutine and yielding from a coroutine automatically switches C stacks. No changes are needed to your Lua source code.
In particular you can now:
- Yield across all metamethods (not advised for __gc).
- Yield across iterator functions (for x in func do).
- Yield across callbacks (table.foreach(), dofile(), ...).
- Yield across protected callbacks (pcall(), xpcall(), ...).
- Yield from C functions and resume back to them.
Coco needs some machine-specific features, but runs fine on Linux, *BSD, Mac OS X, Windows and probably anything else you can find.
More ...
Please click on one of the links in the navigation bar to your left to learn more.
Please visit the Download page to fetch the current version of Coco.
News
2016-07-17 Coco 1.1.9 has been released
GCC inline assembler context switching methods for ARM and ARM64 have been fixed.
Privacy Policy
This web site does not request, store or process any private data.
This web site is fully static and does not allow entry of personal information anywhere. It does not use cookies or any other form of tracking or analytics. Page visits and IP addresses are neither logged nor analyzed.