aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/LuaJIT-1.1.7/jitdoc/coco.html
blob: 0ef43f126e41519778ff59d785d0d432f26b8240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Coco</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Pall">
<meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall">
<meta name="Language" content="en">
<link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
<link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
</head>
<body>
<div id="site">
<a href="http://luajit.org/"><span>Lua<span id="logo">JIT</span></span></a>
</div>
<div id="head">
<h1>Coco</h1>
</div>
<div id="nav">
<ul><li>
<a href="index.html">Index</a>
</li><li>
<a href="luajit.html">LuaJIT</a>
<ul><li>
<a href="luajit_features.html">Features</a>
</li><li>
<a href="luajit_install.html">Installation</a>
</li><li>
<a href="luajit_run.html">Running</a>
</li><li>
<a href="luajit_api.html">API Extensions</a>
</li><li>
<a href="luajit_intro.html">Introduction</a>
</li><li>
<a href="luajit_performance.html">Performance</a>
</li><li>
<a href="luajit_debug.html">Debugging</a>
</li><li>
<a href="luajit_changes.html">Changes</a>
</li></ul>
</li><li>
<a class="current" href="coco.html">Coco</a>
<ul><li>
<a href="coco_portability.html">Portability</a>
</li><li>
<a href="coco_api.html">API Extensions</a>
</li><li>
<a href="coco_changes.html">Changes</a>
</li></ul>
</li><li>
<a href="dynasm.html">DynASM</a>
<ul><li>
<a href="dynasm_features.html">Features</a>
</li><li>
<a href="dynasm_examples.html">Examples</a>
</li></ul>
</li><li>
<a href="http://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
</li></ul>
</div>
<div id="main">
<p>
Coco is a small extension to get <strong>True C&nbsp;Coroutine</strong>
semantics for Lua 5.1.
</p>
<p>
Coco is both available as a stand-alone release and integrated
into <a href="luajit.html">LuaJIT</a> 1.x.
</p>
<p>
The stand-alone release is a patchset against the
<a href="http://www.lua.org/ftp/"><span class="ext">&raquo;</span>&nbsp;standard Lua 5.1.4</a>
distribution. There are no dependencies on LuaJIT. However LuaJIT 1.x
depends on Coco to allow yielding for JIT compiled functions.
</p>
<p>
Coco is Copyright &copy; 2004-2011 Mike Pall.
Coco is free software, released under the
<a href="http://www.opensource.org/licenses/mit-license.php"><span class="ext">&raquo;</span>&nbsp;MIT/X license</a>
(same license as the Lua core).
</p>
<h2>Features</h2>
<p>
True C&nbsp;coroutine semantics mean you can yield from a coroutine
across a C&nbsp;call boundary and resume back to it.
</p>
<p>
Coco allows you to use a dedicated C&nbsp;stack for each coroutine.
Resuming a coroutine and yielding from a coroutine automatically switches
C&nbsp;stacks, too.
</p>
<p>
In particular you can now:
</p>
<ul>
<li>Yield across all metamethods (not advised for <tt>__gc</tt>).</li>
<li>Yield across iterator functions (<tt>for x in func do</tt>).</li>
<li>Yield across callbacks (<tt>table.foreach()</tt>, <tt>dofile()</tt>, ...).</li>
<li>Yield across protected callbacks (<tt>pcall()</tt>, <tt>xpcall()</tt>, ...).</li>
<li>Yield from C&nbsp;functions and resume back to them.</li>
</ul>
<p>
Best of all, you don't need to change your Lua or C&nbsp;sources
and still get the benefits. It's fully integrated into the
Lua core, but tries to minimize the required changes.
</p>

<h2>More ...</h2>
<p>
Please visit the <a href="http://luajit.org/download.html"><span class="ext">&raquo;</span>&nbsp;Download</a> page
to fetch the current version of the stand-alone package.
</p>
<p>
Coco needs some machine-specific features &mdash; please have a look
at the <a href="coco_portability.html">Portability Requirements</a>.
</p>
<p>
Coco also provides some upwards-compatible
<a href="coco_api.html">API Extensions</a> for Lua.
</p>
<br class="flush">
</div>
<div id="foot">
<hr class="hide">
Copyright &copy; 2005-2011 Mike Pall
<span class="noprint">
&middot;
<a href="contact.html">Contact</a>
</span>
</div>
</body>
</html>