aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--docs/index.html89
-rw-r--r--src/lanes.h10
2 files changed, 36 insertions, 63 deletions
diff --git a/docs/index.html b/docs/index.html
index b48c527..f8124c7 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -70,7 +70,7 @@
70 </p> 70 </p>
71 71
72 <p> 72 <p>
73 This document was revised on 23-Feb-24, and applies to version <tt>3.16.3</tt>. 73 This document was revised on 29-Mar-24, and applies to version <tt>4.0.0</tt>.
74 </p> 74 </p>
75 </font> 75 </font>
76 </center> 76 </center>
@@ -88,7 +88,7 @@
88 Lanes is included into your software by the regular <tt>require "lanes"</tt> method. No C side programming is needed; all APIs are Lua side, and most existing extension modules should work seamlessly together with the multiple lanes. 88 Lanes is included into your software by the regular <tt>require "lanes"</tt> method. No C side programming is needed; all APIs are Lua side, and most existing extension modules should work seamlessly together with the multiple lanes.
89</p> 89</p>
90<p> 90<p>
91 Starting with version 3.1.6, Lanes should build and run identically with either Lua 5.1 or Lua 5.2. Version 3.10.0 supports Lua 5.3. 91 Lanes should build and run identically with either Lua 5.1 to Lua 5.4, as well as LuaJIT.
92</p> 92</p>
93<p> 93<p>
94 See <A HREF="comparison.html">comparison</A> of Lua Lanes with other Lua multithreading solutions. 94 See <A HREF="comparison.html">comparison</A> of Lua Lanes with other Lua multithreading solutions.
@@ -152,7 +152,7 @@
152<h2 id="installing">Building and Installing</h2> 152<h2 id="installing">Building and Installing</h2>
153 153
154<p> 154<p>
155 Lua Lanes is built simply by <tt>make</tt> on the supported platforms (<tt>make-vc</tt> for Visual C++). See <tt>README</tt> for system specific details and limitations. 155 Lua Lanes is implemented in C++20. It is built simply by <tt>make</tt> on the supported platforms (<tt>make-vc</tt> for Visual C++). See <tt>README</tt> for system specific details and limitations.
156</p> 156</p>
157 157
158<p> 158<p>
@@ -246,7 +246,7 @@
246</table> 246</table>
247 247
248<p> 248<p>
249 Starting with version 3.0-beta, requiring the module follows Lua 5.2 rules: the module is not available under the global name "lanes", but has to be accessed through <tt>require</tt>'s return value. 249 Requiring the module follows Lua 5.2+ rules: the module is not available under the global name "lanes", but has to be accessed through <tt>require</tt>'s return value.
250</p> 250</p>
251<p> 251<p>
252 After lanes is required, it is necessary to call <tt>lanes.configure()</tt>, which is the only function exposed by the module at this point. Calling <tt>configure()</tt> will perform one-time initializations and make the rest of the API available. 252 After lanes is required, it is necessary to call <tt>lanes.configure()</tt>, which is the only function exposed by the module at this point. Calling <tt>configure()</tt> will perform one-time initializations and make the rest of the API available.
@@ -259,7 +259,7 @@
259 It remains to be seen whether this is actually useful or not: If a module is already threadsafe, protecting its initialization isn't useful. And if it is not, any parallel operation may crash without Lanes being able to do anything about it. 259 It remains to be seen whether this is actually useful or not: If a module is already threadsafe, protecting its initialization isn't useful. And if it is not, any parallel operation may crash without Lanes being able to do anything about it.
260</p> 260</p>
261<p> 261<p>
262 <b>IMPORTANT NOTE:</b> Starting with version 3.7.0, only the first occurence of <tt>require "lanes"</tt> must be followed by a call to <tt>.configure()</tt>. From this point, a simple <tt>require "lanes"</tt> will do wherever you need to require lanes again. 262 <b>IMPORTANT NOTE:</b> Only the first occurence of <tt>require "lanes"</tt> must be followed by a call to <tt>.configure()</tt>. From this point, a simple <tt>require "lanes"</tt> will do wherever you need to require lanes again.
263</p> 263</p>
264 264
265<p> 265<p>
@@ -311,26 +311,12 @@
311 <tt>nil</tt>/<tt>false</tt>/<tt>true</tt> 311 <tt>nil</tt>/<tt>false</tt>/<tt>true</tt>
312 </td> 312 </td>
313 <td> 313 <td>
314 (Since v3.6.3) If equal to <tt>true</tt>, Lanes will collect more information when transfering stuff across Lua states to help identify errors (with a cost). 314 If equal to <tt>true</tt>, Lanes will collect more information when transfering stuff across Lua states to help identify errors (with a cost).
315 Default is <tt>false</tt>. 315 Default is <tt>false</tt>.
316 </td> 316 </td>
317 </tr> 317 </tr>
318 318
319 <tr valign=top> 319 <tr valign=top>
320 <td id="protect_allocator">
321 <code>.protect_allocator</code>
322 </td>
323 <td>
324 <tt>nil</tt>/<tt>false</tt>/<tt>true</tt>
325 </td>
326 <td>
327 REPLACED BY <tt>allocator="protected"</tt> AS OF VERSION v3.13.0.
328 (Since v3.5.2) If equal to <tt>true</tt>, Lanes wraps all calls to the state's allocator function inside a mutex. Since v3.6.3, when left unset, Lanes attempts to autodetect this value for LuaJIT (the guess might be wrong if <tt>"ffi"</tt> isn't loaded though).
329 Default is <tt>true</tt> when Lanes detects it is run by LuaJIT, else <tt>nil</tt>.
330 </td>
331 </tr>
332
333 <tr valign=top>
334 <td id="allocator"> 320 <td id="allocator">
335 <code>.allocator</code> 321 <code>.allocator</code>
336 </td> 322 </td>
@@ -338,7 +324,6 @@
338 <tt>nil</tt>/<tt>"protected"</tt>/function 324 <tt>nil</tt>/<tt>"protected"</tt>/function
339 </td> 325 </td>
340 <td> 326 <td>
341 (Since v3.13.0)<br />
342 If <tt>nil</tt>, Lua states are created with <tt>lua_newstate()</tt> and reuse the allocator from the master state.<br /> 327 If <tt>nil</tt>, Lua states are created with <tt>lua_newstate()</tt> and reuse the allocator from the master state.<br />
343 If <tt>"protected"</tt>, The default allocator obtained from <tt>lua_getallocf()</tt> in the master state is wrapped inside a critical section and used in all newly created states.<br /> 328 If <tt>"protected"</tt>, The default allocator obtained from <tt>lua_getallocf()</tt> in the master state is wrapped inside a critical section and used in all newly created states.<br />
344 If a <tt>function</tt>, this function is called prior to creating the state. It should return a full userdata containing the following structure: 329 If a <tt>function</tt>, this function is called prior to creating the state. It should return a full userdata containing the following structure:
@@ -362,7 +347,6 @@
362 <tt>"libc"</tt>/<tt>"allocator"</tt> 347 <tt>"libc"</tt>/<tt>"allocator"</tt>
363 </td> 348 </td>
364 <td> 349 <td>
365 (Since v3.16.1)<br />
366 Controls which allocator is used for Lanes internal allocations (for keeper, linda and lane management). 350 Controls which allocator is used for Lanes internal allocations (for keeper, linda and lane management).
367 If <tt>"libc"</tt>, Lanes uses <tt>realloc</tt> and <tt>free</tt>.<br /> 351 If <tt>"libc"</tt>, Lanes uses <tt>realloc</tt> and <tt>free</tt>.<br />
368 If <tt>"allocator"</tt>, Lanes uses whatever was obtained from the <tt>"allocator"</tt> setting.<br /> 352 If <tt>"allocator"</tt>, Lanes uses whatever was obtained from the <tt>"allocator"</tt> setting.<br />
@@ -378,7 +362,7 @@
378 <tt>nil</tt>/<tt>false</tt>/<tt>true</tt> 362 <tt>nil</tt>/<tt>false</tt>/<tt>true</tt>
379 </td> 363 </td>
380 <td> 364 <td>
381 (Since v3.7.5) If equal to <tt>false</tt> or <tt>nil</tt>, Lanes raises an error when attempting to transfer a non-deep full userdata, else it will be demoted to a light userdata in the destination. 365 If equal to <tt>false</tt> or <tt>nil</tt>, Lanes raises an error when attempting to transfer a non-deep full userdata, else it will be demoted to a light userdata in the destination.
382 Default is <tt>false</tt> (set to <tt>true</tt> to get the legacy behaviour). 366 Default is <tt>false</tt> (set to <tt>true</tt> to get the legacy behaviour).
383 </td> 367 </td>
384 </tr> 368 </tr>
@@ -415,7 +399,7 @@
415 </ul> 399 </ul>
416 That way, all changes in the state can be properly taken into account when building the function lookup database. Default is <tt>nil</tt>. 400 That way, all changes in the state can be properly taken into account when building the function lookup database. Default is <tt>nil</tt>.
417 <br /> 401 <br />
418 (Since version 3.7.6) If <tt>on_state_create()</tt> is a Lua function, it will be transfered normally before the call. 402 If <tt>on_state_create()</tt> is a Lua function, it will be transfered normally before the call.
419 <br /> 403 <br />
420 If it is a C function, a C closure will be reconstructed in the created state from the C pointer. Lanes will raise an error if the function has upvalues. 404 If it is a C function, a C closure will be reconstructed in the created state from the C pointer. Lanes will raise an error if the function has upvalues.
421 </td> 405 </td>
@@ -429,18 +413,18 @@
429 number >= 0 413 number >= 0
430 </td> 414 </td>
431 <td> 415 <td>
432 (Since v3.3.0) Sets the duration in seconds Lanes will wait for graceful termination of running lanes at application shutdown. Irrelevant for builds using pthreads. Default is <tt>0.25</tt>. 416 Sets the duration in seconds Lanes will wait for graceful termination of running lanes at application shutdown. Irrelevant for builds using pthreads. Default is <tt>0.25</tt>.
433 </td> 417 </td>
434 </tr> 418 </tr>
435 </table> 419 </table>
436</p> 420</p>
437 421
438<p> 422<p>
439 (Since v3.5.0) Once Lanes is configured, one should register with Lanes the modules exporting functions that will be transferred either during lane generation or through <a href="#lindas">lindas</a>. 423 Once Lanes is configured, one should register with Lanes the modules exporting functions that will be transferred either during lane generation or through <a href="#lindas">lindas</a>.
440 <br/> 424 <br/>
441 Use <tt>lanes.require()</tt> for this purpose. This will call the original <tt>require()</tt>, then add the result to the lookup databases. 425 Use <tt>lanes.require()</tt> for this purpose. This will call the original <tt>require()</tt>, then add the result to the lookup databases.
442 <br/> 426 <br/>
443 (Since version 3.11) It is also possible to register a given module with <tt>lanes.register()</tt>. This function will raise an error if the registered module is not a function or table. 427 It is also possible to register a given module with <tt>lanes.register()</tt>. This function will raise an error if the registered module is not a function or table.
444</p> 428</p>
445 429
446<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%"> 430<table border="1" bgcolor="#FFFFE0" cellpadding="10" style="width:50%">
@@ -701,7 +685,7 @@
701 </td> 685 </td>
702 <td>function</td> 686 <td>function</td>
703 <td> 687 <td>
704 (Since version 3.8.2) Callback that gets invoked when the lane is garbage collected. The function receives two arguments (the lane name and a string, either <tt>"closed"</tt> or <tt>"selfdestruct"</tt>). 688 Callback that gets invoked when the lane is garbage collected. The function receives two arguments (the lane name and a string, either <tt>"closed"</tt> or <tt>"selfdestruct"</tt>).
705 </td> 689 </td>
706 </tr> 690 </tr>
707 <tr valign=top> 691 <tr valign=top>
@@ -724,8 +708,6 @@
724 </td> 708 </td>
725 <td> table</td> 709 <td> table</td>
726 <td> 710 <td>
727 Introduced at version 3.0.
728 <br/>
729 Specifying it when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error. 711 Specifying it when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error.
730 <br/> 712 <br/>
731 If not specified, the created lane will receive the current values of <tt>package</tt>. Only <tt>path</tt>, <tt>cpath</tt>, <tt>preload</tt> and <tt>loaders</tt> (Lua 5.1)/<tt>searchers</tt> (Lua 5.2) are transfered. 713 If not specified, the created lane will receive the current values of <tt>package</tt>. Only <tt>path</tt>, <tt>cpath</tt>, <tt>preload</tt> and <tt>loaders</tt> (Lua 5.1)/<tt>searchers</tt> (Lua 5.2) are transfered.
@@ -736,12 +718,12 @@
736<p> 718<p>
737 Each lane also gets a global function <tt>set_debug_threadname()</tt> that it can use anytime to do as the name says. Supported debuggers are Microsoft Visual Studio (for the C side) and Decoda (for the Lua side). 719 Each lane also gets a global function <tt>set_debug_threadname()</tt> that it can use anytime to do as the name says. Supported debuggers are Microsoft Visual Studio (for the C side) and Decoda (for the Lua side).
738 <br/> 720 <br/>
739 Starting with version 3.8.1, the lane has a new method <tt>lane:get_debug_threadname()</tt> that gives access to that name from the caller side (returns <tt>"&lt;unnamed&gt;"</tt> if unset, <tt>"&lt;closed&gt;"</tt> if the internal Lua state is closed). 721 The lane also has a method <tt>lane:get_debug_threadname()</tt> that gives access to that name from the caller side (returns <tt>"&lt;unnamed&gt;"</tt> if unset, <tt>"&lt;closed&gt;"</tt> if the internal Lua state is closed).
740</p> 722</p>
741 723
742<p> 724<p>
743 If a lane body pulls a C function imported by a module required before Lanes itself (thus not through a hooked <tt>require</tt>), the lane generator creation will raise an error. 725 If a lane body pulls a C function imported by a module required before Lanes itself (thus not through a hooked <tt>require</tt>), the lane generator creation will raise an error.
744 The function name it shows is a path where it was found by scanning <tt>_G</tt>. As a utility, the name guessing functionality is exposed as such: 726 The function name it shows is a path where it was found by scanning <tt>_G</tt> and the registry. As a utility, the name guessing functionality is exposed as such:
745 727
746 <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"> 728 <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%">
747 <tr> 729 <tr>
@@ -752,10 +734,6 @@
752 </table> 734 </table>
753</p> 735</p>
754 736
755<p>
756 Starting with version 3.8.3, <tt>lanes.nameof()</tt> searches the registry as well.
757</p>
758
759<h3>Free running lanes</h3> 737<h3>Free running lanes</h3>
760 738
761<p> 739<p>
@@ -892,7 +870,7 @@
892 </td> 870 </td>
893 <td/> 871 <td/>
894 <td> 872 <td>
895 was forcefully killed by <tt>lane_h:cancel()</tt> (since v3.3.0) 873 was forcefully killed by <tt>lane_h:cancel()</tt>
896 </td> 874 </td>
897 </tr> 875 </tr>
898 </table> 876 </table>
@@ -953,7 +931,7 @@
953</pre></td></tr></table> 931</pre></td></tr></table>
954 932
955<p> 933<p>
956 Waits until the lane finishes, or <tt>timeout</tt> seconds have passed. Returns <tt>nil, "timeout"</tt> on timeout (since v3.13), <tt>nil,err,stack_tbl</tt> if the lane hit an error, <tt>nil, "killed"</tt> if forcefully killed (starting with v3.3.0), or the return values of the lane. 934 Waits until the lane finishes, or <tt>timeout</tt> seconds have passed. Returns <tt>nil, "timeout"</tt> on timeout, <tt>nil,err,stack_tbl</tt> if the lane hit an error, <tt>nil, "killed"</tt> if forcefully killed, or the return values of the lane.
957 Unlike in reading the results in table fashion, errors are not propagated. 935 Unlike in reading the results in table fashion, errors are not propagated.
958</p> 936</p>
959 937
@@ -1038,7 +1016,7 @@
1038 If the lane is still running after the timeout expired and <tt>force_kill</tt> is <tt>true</tt>, the OS thread running the lane is forcefully killed. This means no GC, probable OS resource leaks (thread stack, locks, DLL notifications), and should generally be the last resort. 1016 If the lane is still running after the timeout expired and <tt>force_kill</tt> is <tt>true</tt>, the OS thread running the lane is forcefully killed. This means no GC, probable OS resource leaks (thread stack, locks, DLL notifications), and should generally be the last resort.
1039</p> 1017</p>
1040<p> 1018<p>
1041 Cancellation is tested <u>before</u> going to sleep in <tt>receive()</tt> or <tt>send()</tt> calls and after executing <tt>cancelstep</tt> Lua statements. Starting with version 3.0-beta, a pending <tt>receive()</tt>or <tt>send()</tt> call is awakened. 1019 Cancellation is tested <u>before</u> going to sleep in <tt>receive()</tt> or <tt>send()</tt> calls and after executing <tt>cancelstep</tt> Lua statements. A pending <tt>receive()</tt>or <tt>send()</tt> call is awakened.
1042 <br/> 1020 <br/>
1043 This means the execution of the lane will resume although the operation has not completed, to give the lane a chance to detect cancellation (even in the case the code waits on a <a href="#lindas">linda</a> with infinite timeout). 1021 This means the execution of the lane will resume although the operation has not completed, to give the lane a chance to detect cancellation (even in the case the code waits on a <a href="#lindas">linda</a> with infinite timeout).
1044 <br/> 1022 <br/>
@@ -1143,7 +1121,7 @@
1143 <li><tt>receive</tt> has a batched mode to consume more than one value from a single key, as in <tt>linda:receive( 1.0, linda.batched, "key", 3, 6).</tt></li> 1121 <li><tt>receive</tt> has a batched mode to consume more than one value from a single key, as in <tt>linda:receive( 1.0, linda.batched, "key", 3, 6).</tt></li>
1144 <li>individual keys' queue length can be limited, balancing speed differences in a producer/consumer scenario (making <tt>:send</tt> wait).</li> 1122 <li>individual keys' queue length can be limited, balancing speed differences in a producer/consumer scenario (making <tt>:send</tt> wait).</li>
1145 <li><tt>tostring( linda)</tt> returns a string of the form <tt>"Linda: &lt;opt_name&gt;"</tt></li> 1123 <li><tt>tostring( linda)</tt> returns a string of the form <tt>"Linda: &lt;opt_name&gt;"</tt></li>
1146 <li>several lindas may share the same keeper state. Since version 3.9.1, state assignation can be controlled with the linda's group (an integer). All lindas belonging to the same group will share the same keeper state. One keeper state may be shared by several groups.</li> 1124 <li>several lindas may share the same keeper state. State assignation can be controlled with the linda's group (an integer). All lindas belonging to the same group will share the same keeper state. One keeper state may be shared by several groups.</li>
1147 </ul> 1125 </ul>
1148</p> 1126</p>
1149 1127
@@ -1168,7 +1146,7 @@
1168 <br/> 1146 <br/>
1169 A limit of 0 is allowed to block everything. 1147 A limit of 0 is allowed to block everything.
1170 <br/> 1148 <br/>
1171 (Since version 3.7.7) 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. 1149 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.
1172</p> 1150</p>
1173 1151
1174<p> 1152<p>
@@ -1182,9 +1160,9 @@
1182<p> 1160<p>
1183 <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. 1161 <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.
1184 <br/> 1162 <br/>
1185 (Since version 3.7.8) <tt>send()</tt> returns <tt>lanes.cancel_error</tt> if interrupted by a soft cancel request. 1163 <tt>send()</tt> returns <tt>lanes.cancel_error</tt> if interrupted by a soft cancel request.
1186 <br/> 1164 <br/>
1187 If no data is provided after the key, <tt>send()</tt> raises an error. Since version 3.9.3, if provided with <tt>linda.null</tt> before the actual key and there is no data to send, <tt>send()</tt> sends a single <tt>nil</tt>. 1165 If no data is provided after the key, <tt>send()</tt> raises an error. If provided with <tt>linda.null</tt> before the actual key and there is no data to send, <tt>send()</tt> sends a single <tt>nil</tt>.
1188 <br/> 1166 <br/>
1189 Also, if <tt>linda.null</tt> is sent as data in a linda, it will be read as a <tt>nil</tt>. 1167 Also, if <tt>linda.null</tt> is sent as data in a linda, it will be read as a <tt>nil</tt>.
1190</p> 1168</p>
@@ -1192,9 +1170,7 @@
1192<p> 1170<p>
1193 Equally, <tt>receive()</tt> returns a key and the value extracted from it, or nothing for timeout. Note that <tt>nil</tt>s can be sent and received; the <tt>key</tt> value will tell it apart from a timeout. 1171 Equally, <tt>receive()</tt> returns a key and the value extracted from it, or nothing for timeout. Note that <tt>nil</tt>s can be sent and received; the <tt>key</tt> value will tell it apart from a timeout.
1194 <br/> 1172 <br/>
1195 Version 3.4.0 introduces an API change in the returned values: <tt>receive()</tt> returns the key followed by the value(s), in that order, and not the other way around. 1173 <tt>receive()</tt> returns <tt>lanes.cancel_error</tt> if interrupted by a soft cancel request.
1196 <br/>
1197 (Since version 3.7.8) <tt>receive()</tt> returns <tt>lanes.cancel_error</tt> if interrupted by a soft cancel request.
1198</p> 1174</p>
1199 1175
1200<p> 1176<p>
@@ -1225,17 +1201,17 @@
1225<p> 1201<p>
1226 <tt>set()</tt> signals the linda for write if a value is stored. If nothing special happens, <tt>set() </tt>returns nothing. 1202 <tt>set()</tt> signals the linda for write if a value is stored. If nothing special happens, <tt>set() </tt>returns nothing.
1227 <br/> 1203 <br/>
1228 Since version 3.7.7, if the key was full but the new data count of the key after <tt>set()</tt> is below its limit, <tt>set()</tt> returns <tt>true</tt> and the linda is also signaled for read so that <tt>send()</tt>-blocked threads are awakened. 1204 If the key was full but the new data count of the key after <tt>set()</tt> is below its limit, <tt>set()</tt> returns <tt>true</tt> and the linda is also signaled for read so that <tt>send()</tt>-blocked threads are awakened.
1229</p> 1205</p>
1230 1206
1231<p> 1207<p>
1232 Since version 3.8.0, <tt>set()</tt> can write several values at the specified key, writing <tt>nil</tt> values is now possible, and clearing the contents at the specified key is done by not providing any value. 1208 <tt>set()</tt> can write several values at the specified key, writing <tt>nil</tt> values is now possible, and clearing the contents at the specified key is done by not providing any value.
1233 <br/> 1209 <br/>
1234 Also, <tt>get()</tt> can read several values at once. If the key contains no data, <tt>get()</tt> returns no value. This can be used to separate the case when reading stored <tt>nil</tt> values. 1210 Also, <tt>get()</tt> can read several values at once. If the key contains no data, <tt>get()</tt> returns no value. This can be used to separate the case when reading stored <tt>nil</tt> values.
1235</p> 1211</p>
1236 1212
1237<p> 1213<p>
1238 Since version 3.8.4, trying to send or receive data through a cancelled linda does nothing and returns <tt>lanes.cancel_error</tt>. 1214 Trying to send or receive data through a cancelled linda does nothing and returns <tt>lanes.cancel_error</tt>.
1239</p> 1215</p>
1240 1216
1241<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> 1217<table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre>
@@ -1267,7 +1243,7 @@
1267</pre></td></tr></table> 1243</pre></td></tr></table>
1268 1244
1269<p> 1245<p>
1270 (Starting with version 3.8.4) Signals the linda so that lanes waiting for read, write, or both, wake up. 1246 Signals the linda so that lanes waiting for read, write, or both, wake up.
1271 All linda operations (including <tt>get()</tt> and <tt>set()</tt>) will return <tt>lanes.cancel_error</tt> as when the calling lane is <a href="#cancelling">soft-cancelled</a> as long as the linda is marked as cancelled. 1247 All linda operations (including <tt>get()</tt> and <tt>set()</tt>) will return <tt>lanes.cancel_error</tt> as when the calling lane is <a href="#cancelling">soft-cancelled</a> as long as the linda is marked as cancelled.
1272 <br/> 1248 <br/>
1273 <tt>"none"</tt> reset the linda's cancel status, but doesn't signal it. 1249 <tt>"none"</tt> reset the linda's cancel status, but doesn't signal it.
@@ -1404,7 +1380,7 @@ events to a common Linda, but... :).</font>
1404</pre></td></tr></table> 1380</pre></td></tr></table>
1405 1381
1406<p> 1382<p>
1407 (Since version 3.9.7) A very simple way of sleeping when nothing else is available. Is implemented by attempting to read some data in an unused channel of the internal linda used for timers (this linda exists even when timers aren't enabled). 1383 A very simple way of sleeping when nothing else is available. Is implemented by attempting to read some data in an unused channel of the internal linda used for timers (this linda exists even when timers aren't enabled).
1408 Default duration is null, which should only cause a thread context switch. 1384 Default duration is null, which should only cause a thread context switch.
1409</p> 1385</p>
1410 1386
@@ -1470,9 +1446,6 @@ events to a common Linda, but... :).</font>
1470<p> 1446<p>
1471 <ul> 1447 <ul>
1472 <li>Booleans, numbers, strings, light userdata, Lua functions and tables of such can always be passed.</li> 1448 <li>Booleans, numbers, strings, light userdata, Lua functions and tables of such can always be passed.</li>
1473 <ul>
1474 <li>Versions 3.4.1 and earlier had an undocumented limitation: Lua functions with an indirect recursive Lua function upvalue raised an error when transfered. This limitation disappeared with version 3.4.2.</li>
1475 </ul>
1476 <li> 1449 <li>
1477 Cyclic tables and/or duplicate references are allowed and reproduced appropriately, but only <u>within the same transmission</u>. 1450 Cyclic tables and/or duplicate references are allowed and reproduced appropriately, but only <u>within the same transmission</u>.
1478 <ul> 1451 <ul>
@@ -1501,7 +1474,7 @@ events to a common Linda, but... :).</font>
1501 </ul> 1474 </ul>
1502 </li> 1475 </li>
1503 <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> 1476 <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>
1504 <li>Starting with version 3.10.1, if the metatable contains <tt>__lanesignore</tt>, the object is skipped and <tt>nil</tt> is transfered instead.</li> 1477 <li>If the metatable contains <tt>__lanesignore</tt>, the object is skipped and <tt>nil</tt> is transfered instead.</li>
1505 </ul> 1478 </ul>
1506</p> 1479</p>
1507 1480
@@ -1615,10 +1588,10 @@ events to a common Linda, but... :).</font>
1615 1588
1616<h3 id="clonable_userdata">Clonable full userdata in your own apps</h3> 1589<h3 id="clonable_userdata">Clonable full userdata in your own apps</h3>
1617<p> 1590<p>
1618 Starting with version 3.13.0, a new way of passing full userdata across lanes uses a new <tt>__lanesclone</tt> metamethod. 1591 An alternative way of passing full userdata across lanes uses a new <tt>__lanesclone</tt> metamethod.
1619 When a deep userdata is cloned, Lanes calls <tt>__lanesclone</tt> once, in the context of the source lane.</br> 1592 When a deep userdata is cloned, Lanes calls <tt>__lanesclone</tt> once, in the context of the source lane.</br>
1620 The call receives the clone and original as light userdata, plus the actual userdata size, as in <tt>clone:__lanesclone(original,size)</tt>, and should perform the actual cloning.</br> 1593 The call receives the clone and original as light userdata, plus the actual userdata size, as in <tt>clone:__lanesclone(original,size)</tt>, and should perform the actual cloning.</br>
1621 A typical implementation would look like (BEWARE, THIS CHANGED WITH VERSION 3.16.0): 1594 A typical implementation would look like:
1622<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>
1623static int clonable_lanesclone( lua_State* L) 1596static int clonable_lanesclone( lua_State* L)
1624{ 1597{
@@ -1696,7 +1669,7 @@ int luaD_new_clonable( lua_State* L)
1696 <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> void* idfunc( lua_State* L, DeepOp op_);</pre></td></tr></table> 1669 <table border="1" bgcolor="#E0E0FF" cellpadding="10" style="width:50%"><tr><td><pre> void* idfunc( lua_State* L, DeepOp op_);</pre></td></tr></table>
1697 <tt>op_</tt> can be one of: 1670 <tt>op_</tt> can be one of:
1698 <ul> 1671 <ul>
1699 <li><tt>eDO_new</tt>: requests the creation of a new object, whose pointer is returned. Starting with version 3.13.0, object should embed <tt>DeepPrelude</tt> structure as header and initialize its <tt>magic</tt> member with the current <tt>DEEP_VERSION</tt>.</li> 1672 <li><tt>eDO_new</tt>: requests the creation of a new object, whose pointer is returned. Said object must derive from <tt>DeepPrelude</tt>.</li>
1700 <li><tt>eDO_delete</tt>: receives this same pointer on the stack as a light userdata, and should cleanup the object.</li> 1673 <li><tt>eDO_delete</tt>: receives this same pointer on the stack as a light userdata, and should cleanup the object.</li>
1701 <li><tt>eDO_metatable</tt>: should build a metatable for the object. Don't cache the metatable yourself, Lanes takes care of it (<tt>eDO_metatable</tt> should only be invoked once per state). Just push the metatable on the stack.</li> 1674 <li><tt>eDO_metatable</tt>: should build a metatable for the object. Don't cache the metatable yourself, Lanes takes care of it (<tt>eDO_metatable</tt> should only be invoked once per state). Just push the metatable on the stack.</li>
1702 <li><tt>eDO_module</tt>: requests the name of the module that exports the idfunc, to be returned. It is necessary so that Lanes can require it in any lane state that receives a userdata. This is to prevent crashes in situations where the module could be unloaded while the idfunc pointer is still held.</li> 1675 <li><tt>eDO_module</tt>: requests the name of the module that exports the idfunc, to be returned. It is necessary so that Lanes can require it in any lane state that receives a userdata. This is to prevent crashes in situations where the module could be unloaded while the idfunc pointer is still held.</li>
diff --git a/src/lanes.h b/src/lanes.h
index 6e05cae..05a0a5c 100644
--- a/src/lanes.h
+++ b/src/lanes.h
@@ -10,9 +10,9 @@ extern "C" {
10 10
11#include "lanesconf.h" 11#include "lanesconf.h"
12 12
13#define LANES_VERSION_MAJOR 3 13#define LANES_VERSION_MAJOR 4
14#define LANES_VERSION_MINOR 16 14#define LANES_VERSION_MINOR 0
15#define LANES_VERSION_PATCH 3 15#define LANES_VERSION_PATCH 0
16 16
17#define LANES_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR>MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR>MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH>=PATCH)))) 17#define LANES_MIN_VERSION_REQUIRED(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR>MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR>MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH>=PATCH))))
18#define LANES_VERSION_LESS_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR<MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR<MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH<PATCH)))) 18#define LANES_VERSION_LESS_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR<MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR<MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH<PATCH))))
@@ -20,7 +20,7 @@ extern "C" {
20#define LANES_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR>MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR>MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH>PATCH)))) 20#define LANES_VERSION_GREATER_THAN(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR>MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR>MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH>PATCH))))
21#define LANES_VERSION_GREATER_OR_EQUAL(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR>MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR>MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH>=PATCH)))) 21#define LANES_VERSION_GREATER_OR_EQUAL(MAJOR, MINOR, PATCH) ((LANES_VERSION_MAJOR>MAJOR) || (LANES_VERSION_MAJOR==MAJOR && (LANES_VERSION_MINOR>MINOR || (LANES_VERSION_MINOR==MINOR && LANES_VERSION_PATCH>=PATCH))))
22 22
23LANES_API int luaopen_lanes_core( lua_State* L); 23LANES_API int luaopen_lanes_core(lua_State* L);
24 24
25// Call this to work with embedded Lanes instead of calling luaopen_lanes_core() 25// Call this to work with embedded Lanes instead of calling luaopen_lanes_core()
26LANES_API void luaopen_lanes_embedded( lua_State* L, lua_CFunction _luaopen_lanes); 26LANES_API void luaopen_lanes_embedded(lua_State* L, lua_CFunction _luaopen_lanes);