aboutsummaryrefslogtreecommitdiff
path: root/docs/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/index.html')
-rw-r--r--docs/index.html91
1 files changed, 44 insertions, 47 deletions
diff --git a/docs/index.html b/docs/index.html
index 60f4970..24c7c52 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -546,7 +546,7 @@
546 </td> 546 </td>
547 <td /> 547 <td />
548 <td> 548 <td>
549 root level names, <tt>print</tt>, <tt>assert</tt>, <tt>unpack</tt> etc. 549 <tt>_G</tt> namespace (the default function environment): <tt>print</tt>, <tt>assert</tt>, <tt>dofile</tt>, etc.
550 </td> 550 </td>
551 </tr> 551 </tr>
552 <tr> 552 <tr>
@@ -1150,13 +1150,13 @@
1150<h2 id="lindas">Lindas</h2> 1150<h2 id="lindas">Lindas</h2>
1151 1151
1152<p> 1152<p>
1153 Communications between lanes is completely detached from the lane handles themselves. By itself, a lane can only provide return values once it's finished, or throw an error. 1153 Communications between lanes is completely detached from the lane handles themselves. By itself, a lane can only provide return values once it is finished, or throw an error.
1154 Needs to communicate during runtime are handled by <a href="http://en.wikipedia.org/wiki/Linda_%28coordination_language%29" target="_blank">Linda objects</a>, which are 1154 Needs to communicate during runtime are handled by <a href="http://en.wikipedia.org/wiki/Linda_%28coordination_language%29" target="_blank">Linda objects</a>, which are
1155 <a href="#deep_userdata">deep userdata</a> instances. They can be provided to a lane as startup parameters, upvalues or in some other Linda's message. 1155 <a href="#deep_userdata">deep userdata</a> instances. They can be provided to a lane as startup parameters, upvalues or in some other Linda's message.
1156</p> 1156</p>
1157 1157
1158<p> 1158<p>
1159 Access to a Linda object means a lane can read or write to any of its data slots. Multiple lanes can be accessing the same Linda in parallel. No application level locking is required; each Linda operation is atomic. 1159 Access to a Linda object means a lane can read or write to any of its data slots. Multiple lanes can be accessing the same Linda simultaneously. Seen from Lua, no application level locking is required; each Linda operation is atomic.
1160</p> 1160</p>
1161 1161
1162<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre> 1162<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre>
@@ -1212,35 +1212,53 @@
1212 1212
1213<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> 1213<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre>
1214 h = lanes.linda([opt_name, [opt_group]]) 1214 h = lanes.linda([opt_name, [opt_group]])
1215</pre></td></tr></table>
1215 1216
1216 true|lanes.cancel_error = h:send([timeout_secs,] key, ...) 1217<p>
1218 Converting the Linda to a string will yield the provided name prefixed by <tt>"Linda: "</tt>.<br/>
1219 If <tt>opt_name</tt> is omitted, it will evaluate to an hexadecimal number uniquely representing that Linda when the Linda is converted to a string. The value is the same as returned by <tt>linda:deep()</tt>.<br/>
1220 If <tt>opt_name</tt> is <tt>"auto"</tt>, Lanes will try to construct a name from the source location that called <tt>lanes.linda()</tt>. If that fails, the Linda name will be <tt>"&lt;unresolved&gt;"</tt>.
1221</p>
1217 1222
1218 key, val = h:receive([timeout_secs,] key [, key...]) 1223<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre>
1224 true|lanes.cancel_error = h:limit(key, n_uint)
1225</pre></td></tr></table>
1219 1226
1220 key, val [, val...] = h:receive(timeout, h.batched, key, n_uint_min[, n_uint_max]) 1227<p>
1228 By default, queue sizes are unlimited but limits can be enforced using the <tt>limit()</tt> method. This can be useful to balance execution speeds in a producer/consumer scenario. <tt>nil</tt> removes the limit.<br/>
1229 A limit of 0 is allowed to block everything.<br/>
1230 If the key was full but the limit change added some room, <tt>limit()</tt> returns <tt>true</tt> and the Linda is signalled so that <tt>send()</tt>-blocked threads are awakened.<br/>
1231</p>
1221 1232
1222 true|lanes.cancel_error = h:limit(key, n_uint) 1233<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre>
1234 true|lanes.cancel_error = h:send([timeout_secs,] key, ...)
1223</pre></td></tr></table> 1235</pre></td></tr></table>
1224 1236
1225<p> 1237<p>
1226 Converting the Linda to a string will yield the provided name prefixed by <tt>"Linda: "</tt>.<br/> 1238 Timeouts are given in seconds (&gt= 0, millisecond accuracy) or <tt>nil</tt>. Timeout can be omitted only if the first key is not a number (then it is equivalent to an infinite duration).<br/>
1227 If <tt>opt_name</tt> is omitted, it will evaluate to an hexadecimal number uniquely representing that Linda when the Linda is converted to a string. The value is the same as returned by <tt>linda:deep()</tt>.<br/> 1239 Each key acts as a FIFO queue. There is no limit to the number of keys a Linda may contain. Different Lindas can have identical keys, which are totally unrelated.
1228 If <tt>opt_name</tt> is <tt>"auto"</tt>, Lanes will try to construct a name from the source location that called <tt>lanes.linda()</tt>. If that fails, the Linda name will be <tt>"&lt;unresolved&gt;"</tt>.
1229</p> 1240</p>
1230<p> 1241<p>
1231 Timeouts are given in seconds (&gt= 0, millisecond accuracy) or <tt>nil</tt>. Timeout can be omitted only if the first key is not a number (then it's equivalent to an infinite duration). 1242 If no data is provided after the key, <tt>send()</tt> raises an error.<br/>
1243 Also, if <tt>linda.null</tt> or <tt>lanes.null</tt> is sent as data in a Linda, it will be read as a <tt>nil</tt>.<br/>
1244 <tt>send()</tt> returns <tt>true</tt> if the sending succeeded, and <tt>false</tt> if the queue limit was met, and the queue did not empty enough during the given timeout.<br/>
1245 <tt>send()</tt> returns <tt>lanes.cancel_error</tt> if interrupted by a soft cancel request.<br/>
1232</p> 1246</p>
1233 1247
1248<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre>
1249 key, val = h:receive([timeout_secs,] key [, key...])
1250
1251 key, val [, val...] = h:receive(timeout, h.batched, key, n_uint_min[, n_uint_max])
1252</pre></td></tr></table>
1253
1254
1234<p> 1255<p>
1235 The <tt>send()</tt> and <tt>receive()</tt> methods use Linda keys as FIFO stacks (first in, first out).<br/> 1256 The <tt>send()</tt> and <tt>receive()</tt> methods use Linda keys as FIFO stacks (first in, first out).<br/>
1236 By default, stack sizes are unlimited but limits can be enforced using the <tt>limit()</tt> method. This can be useful to balance execution speeds in a producer/consumer scenario. <tt>nil</tt> removes the limit.<br/>
1237 A limit of 0 is allowed to block everything.<br/>
1238 If the key was full but the limit change added some room, <tt>limit()</tt> returns <tt>true</tt> and the Linda is signalled so that <tt>send()</tt>-blocked threads are awakened.<br/>
1239 In batched mode, <tt>linda:receive()</tt> will raise an error if <tt>min_count < 1</tt> or <tt>max_count < min_count</tt>. 1257 In batched mode, <tt>linda:receive()</tt> will raise an error if <tt>min_count < 1</tt> or <tt>max_count < min_count</tt>.
1240</p> 1258</p>
1241 1259
1242<p> 1260<p>
1243 Note that any number of lanes can be reading or writing a Linda. There can be many producers, and many consumers. It's up to you. 1261 Note that any number of lanes can be reading or writing a Linda. There can be many producers, and many consumers. It is up to you.
1244</p> 1262</p>
1245 1263
1246<p> 1264<p>
@@ -1248,16 +1266,6 @@
1248</p> 1266</p>
1249 1267
1250<p> 1268<p>
1251 <tt>send()</tt> returns <tt>true</tt> if the sending succeeded, and <tt>false</tt> if the queue limit was met, and the queue did not empty enough during the given timeout.
1252 <br/>
1253 <tt>send()</tt> returns <tt>lanes.cancel_error</tt> if interrupted by a soft cancel request.
1254 <br/>
1255 If no data is provided after the key, <tt>send()</tt> raises an error.
1256 <br/>
1257 Also, if <tt>linda.null</tt> or <tt>lanes.null</tt> is sent as data in a Linda, it will be read as a <tt>nil</tt>.
1258</p>
1259
1260<p>
1261 Equally, <tt>receive()</tt> returns a key and the value extracted from it. Note that <tt>nil</tt>s can be sent and received; the <tt>key</tt> value will tell it apart from a timeout.<br/> 1269 Equally, <tt>receive()</tt> returns a key and the value extracted from it. Note that <tt>nil</tt>s can be sent and received; the <tt>key</tt> value will tell it apart from a timeout.<br/>
1262 <tt>receive()</tt> returns <tt>nil, lanes.cancel_error</tt> if interrupted by a hard cancel request.<br/> 1270 <tt>receive()</tt> returns <tt>nil, lanes.cancel_error</tt> if interrupted by a hard cancel request.<br/>
1263 <tt>receive()</tt> returns <tt>nil, "timeout"</tt> if nothing was available. 1271 <tt>receive()</tt> returns <tt>nil, "timeout"</tt> if nothing was available.
@@ -1558,14 +1566,22 @@ On the other side, you need to use a common Linda for waiting for multiple keys.
1558 to the global table in the destination state. Note that this also applies when Lanes is built for Lua 5.1, as it doesn't hurt. 1566 to the global table in the destination state. Note that this also applies when Lanes is built for Lua 5.1, as it doesn't hurt.
1559 </li> 1567 </li>
1560 <li> 1568 <li>
1561 Full userdata can be passed only if it's prepared using the <a href="#deep_userdata">deep userdata</a> system, which handles its lifespan management 1569 Full userdata can be passed only if it is prepared using the <a href="#deep_userdata">deep userdata</a> system, which handles its lifespan management
1562 <ul> 1570 <ul>
1563 <li>In particular, lane handles cannot be passed between lanes.</li> 1571 <li>In particular, lane handles cannot be passed between lanes.</li>
1564 <li>Lanes can either throw an error or attempt a <a href="#demote_full_userdata">light userdata demotion</a>.</li> 1572 <li>Lanes can either throw an error or attempt a <a href="#demote_full_userdata">light userdata demotion</a>.</li>
1565 </ul> 1573 </ul>
1566 </li> 1574 </li>
1567 <li>Coroutines cannot be passed. A coroutine's Lua state is tied to the Lua state that created it, and there is no way the mixed C/Lua stack of a coroutine can be transfered from one Lua state to another.</li> 1575 <li>Coroutines cannot be passed. A coroutine's Lua state is tied to the Lua state that created it, and there is no way the mixed C/Lua stack of a coroutine can be transfered from one Lua state to another.</li>
1568 <li>If the metatable contains <tt>__lanesignore</tt>, the object is skipped and <tt>nil</tt> is transfered instead.</li> 1576 <li>
1577 If the metatable contains <tt>__lanesconvert</tt>, the object is converted as follows depending on the value:
1578 <ul>
1579 <li><tt>lanes.null</tt>: The value is converted to <tt>nil</tt>.</li>
1580 <li><tt>"decay"</tt>: The value is converted to a light userdata obtained from <tt>lua_topointer()</tt>.</li>
1581 <li>A function: The function is called as <tt>o:__lanesconvert(string)</tt>, where the argument is either <tt>"keeper"</tt> or <tt>"regular"</tt>, depending on the type of destination. Its (single) return value is the result of the conversion.</li>
1582 <li>Any other value raises an error.</li>
1583 </ul>
1584 </li>
1569 </ul> 1585 </ul>
1570</p> 1586</p>
1571 1587
@@ -1573,26 +1589,7 @@ On the other side, you need to use a common Linda for waiting for multiple keys.
1573<h3 id="function_notes">Notes about passing C functions</h3> 1589<h3 id="function_notes">Notes about passing C functions</h3>
1574 1590
1575<p> 1591<p>
1576 Originally, a C function was copied from one Lua state to another as follows: 1592 Functions are transfered as follows (more or less):
1577</p>
1578
1579<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre>
1580 // expects a C function on top of the source Lua stack
1581 copy_func(lua_State *dest, lua_State* source)
1582 {
1583 // extract C function pointer from source
1584 lua_CFunction func = lua_tocfunction(source, -1);
1585 // transfer upvalues
1586 int nup = transfer_upvalues(dest, source);
1587 // dest Lua stack contains a copy of all upvalues
1588 lua_pushcfunction(dest, func, nup);
1589 }
1590</pre></td></tr></table>
1591
1592<p>
1593 This has the main drawback of not being LuaJIT-compatible, because some functions registered by LuaJIT are not regular C functions, but specially optimized implementations. As a result, <tt>lua_tocfunction()</tt> returns <tt>nullptr</tt> for them.
1594 <br/>
1595 Therefore, Lanes no longer transfers functions that way. Instead, functions are transfered as follows (more or less):
1596</p> 1593</p>
1597 1594
1598<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre> 1595<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"><tr><td><pre>