aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/index.html117
1 files changed, 107 insertions, 10 deletions
diff --git a/docs/index.html b/docs/index.html
index 3c4fe59..3c9abfe 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -54,9 +54,9 @@
54 <a href="#changes">Change log</a> 54 <a href="#changes">Change log</a>
55 <!-- ... --> 55 <!-- ... -->
56 56
57<p><br/><font size="-1"><i>Copyright &copy; 2007-11 Asko Kauppi. All rights reserved.</i> 57<p><br/><font size="-1"><i>Copyright &copy; 2007-12 Asko Kauppi, Benoit Germain. All rights reserved.</i>
58 <br>Lua Lanes is published under the same <A HREF="http://en.wikipedia.org/wiki/MIT_License">MIT license</A> as Lua 5.1. 58 <br>Lua Lanes is published under the same <A HREF="http://en.wikipedia.org/wiki/MIT_License">MIT license</A> as Lua 5.1.
59 </p><p>This document was revised on 1-Mar-11, and applies to version 2.1.0. 59 </p><p>This document was revised on 5-Nov-11, and applies to version 3.0-beta.
60</font></p> 60</font></p>
61 61
62</center> 62</center>
@@ -162,7 +162,51 @@ Or use <A HREF="http://www.luarocks.org" TARGET="_blank">Lua Rocks</A> package m
162 162
163<!-- launching +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> 163<!-- launching +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
164<hr/> 164<hr/>
165<h2 id="creation">Creation</h2> 165
166 <h2 id="initialization">Initialization</h2>
167
168 <p>
169 The following sample shows how to initialize the Lanes module.
170 </p>
171
172 <table border="1" bgcolor="#FFFFE0" width="500">
173 <tr>
174 <td>
175 <pre>
176 local lanes = require "lanes"
177 lanes.configure( 1)
178 </pre>
179 </table>
180
181 <p>
182 Starting with version 3.0-beta, requiring the module follows Lua 5.2 rules:
183 the module is not available under the global name "lanes", but has to be accessed
184 through require's return value.
185 After lanes is required, it is necessary to call lanes.configure(), which is the
186 only function exposed by the module at this point. Calling configure() will
187 perform one-time initializations and make the rest of the API available.
188 At the same time, configure() itself will be replaced by another function that
189 raises an error if called with differing arguments.
190 </p>
191
192 <p>
193 <table border="1" bgcolor="#E0E0FF" cellpadding="10">
194 <tr>
195 <td>
196 <code>
197 lanes.configure( [nb_keepers] [, "NO_TIMERS"])
198 </code>
199 </table>
200 </p>
201 <p>
202 <tt>lanes.configure</tt> accepts 2 arguments. The first one controls the number
203 of keeper states used internally by lindas to transfer data between lanes. (see below).
204 Default is 1.
205 </p>
206 <p>If the second argument is equal to <tt>"NO_TIMERS"</tt>, Lanes doesn't start the timer service,
207 and the associated API will be absent from the interface (see below).
208 </p>
209 <h2 id="creation">Creation</h2>
166 210
167<p>The following sample shows preparing a function for parallel calling, and 211<p>The following sample shows preparing a function for parallel calling, and
168calling it with varying arguments. Each of the two results is calculated in 212calling it with varying arguments. Each of the two results is calculated in
@@ -172,7 +216,8 @@ joins the threads, waiting for any results not already there.
172 216
173<table border=1 bgcolor="#FFFFE0" width=500><tr><td> 217<table border=1 bgcolor="#FFFFE0" width=500><tr><td>
174<pre> 218<pre>
175 require "lanes" 219 local lanes = require "lanes"
220 lanes.configure( 1)
176 221
177 f= lanes.gen( function(n) return 2*n end ) 222 f= lanes.gen( function(n) return 2*n end )
178 a= f(1) 223 a= f(1)
@@ -189,7 +234,7 @@ joins the threads, waiting for any results not already there.
189 lane_h= func( ... )</code> 234 lane_h= func( ... )</code>
190</table> 235</table>
191</p> 236</p>
192</p><p> 237<p>
193 The function returned by <tt>lanes.gen()</tt> is a "generator" for 238 The function returned by <tt>lanes.gen()</tt> is a "generator" for
194 launching any number of lanes. They will share code, options, initial globals, 239 launching any number of lanes. They will share code, options, initial globals,
195 but the particular arguments may vary. Only calling the generator function 240 but the particular arguments may vary. Only calling the generator function
@@ -256,6 +301,23 @@ also in the new lanes.
256 modifying one will only affect the particular lane. 301 modifying one will only affect the particular lane.
257 </td></tr> 302 </td></tr>
258 303
304 <tr valign="top">
305 <td/>
306 <td>
307 <code>.required</code> <br/>modules_tbl
308 </td>
309 <td>
310 Lists modules that have to be required in order to be able to trasnfer
311 functions they exposed. Starting with Lanes 3.0-beta, non-Lua functions are
312 no longer copied by recreating a C closure from a C pointer, but are searched
313 in lookup tables. These tables are built from the modules listed here. <tt>required</tt>
314 must be a list of strings, each one being the name of a module to be required.
315 <br>
316 The global values of different lanes are in no manner connected;
317 modifying one will only affect the particular lane.
318 </td>
319 </tr>
320
259 <tr valign=top><td width=40><td> 321 <tr valign=top><td width=40><td>
260 <code>.priority</code> <br/><nobr>-2..+2</nobr></td> 322 <code>.priority</code> <br/><nobr>-2..+2</nobr></td>
261 <td>The priority of lanes generated. -2 is lowest, +2 is highest. 323 <td>The priority of lanes generated. -2 is lowest, +2 is highest.
@@ -273,6 +335,7 @@ also in the new lanes.
273 <td> 335 <td>
274 <code>package.path</code> and <code>package.cpath</code> overrides, if needed. 336 <code>package.path</code> and <code>package.cpath</code> overrides, if needed.
275 Specifying these when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error. 337 Specifying these when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error.
338 If not specified, the created lane will receive the current values of <tt>package.path</tt> and <tt>package.cpath</tt>.
276 <br> 339 <br>
277 </td> 340 </td>
278 </tr> 341 </tr>
@@ -407,8 +470,9 @@ OS thread running the lane is forcefully killed. This means no GC, and should
407generally be the last resort. 470generally be the last resort.
408</p> 471</p>
409<p>Cancellation is tested <u>before</u> going to sleep in <tt>receive()</tt> or <tt>send()</tt> calls 472<p>Cancellation is tested <u>before</u> going to sleep in <tt>receive()</tt> or <tt>send()</tt> calls
410and after executing <tt>cancelstep</tt> Lua statements. A currently pending <tt>receive()</tt> 473and after executing <tt>cancelstep</tt> Lua statements. Starting with version 3.0-beta, a pending <tt>receive()</tt>
411or <tt>send()</tt> call is currently not awakened, and may be a reason for a non-detected cancel. 474or <tt>send()</tt> call is awakened. This means the execution of the lane will resume although the operation has
475not completed, to give the lane a chance to detect cancellation. The code should be able to handle this situation appropriately if required.
412It is also possible to manually test for cancel requests with <tt>cancel_test()</tt>. 476It is also possible to manually test for cancel requests with <tt>cancel_test()</tt>.
413</p> 477</p>
414 478
@@ -619,6 +683,8 @@ you want to use several?
619 <li>Performance. Changing any slot in a Linda causes all pending threads 683 <li>Performance. Changing any slot in a Linda causes all pending threads
620 for that Linda to be momentarily awakened (at least in the C level). 684 for that Linda to be momentarily awakened (at least in the C level).
621 This can degrade performance due to unnecessary OS level context switches. 685 This can degrade performance due to unnecessary OS level context switches.
686 The more keeper states you declared with <tt>lanes.configure()</tt> the less
687 this should be a problem.
622 </li> 688 </li>
623</ul> 689</ul>
624 690
@@ -639,6 +705,10 @@ events to a common Linda, but... :).</font>
639 <code>= lanes.timer( linda_h, key, date_tbl|first_secs [,period_secs] )</code> 705 <code>= lanes.timer( linda_h, key, date_tbl|first_secs [,period_secs] )</code>
640</table> 706</table>
641 707
708 <p>
709 Timers are implemented as a lane. They can be disabled by passing <tt>"NO_TIMERS"</tt>
710 to <tt>lanes.configure()</tt>.
711 </p>
642<p> 712<p>
643Timers can be run once, or in a reoccurring fashion (<tt>period_secs > 0</tt>). 713Timers can be run once, or in a reoccurring fashion (<tt>period_secs > 0</tt>).
644The first occurrence can be given either as a date or as a relative delay in seconds. 714The first occurrence can be given either as a date or as a relative delay in seconds.
@@ -655,7 +725,8 @@ A timer can be stopped simply by <tt>first_secs=0</tt> and no period.
655 725
656<table border=1 bgcolor="#FFFFE0" width=500><tr><td> 726<table border=1 bgcolor="#FFFFE0" width=500><tr><td>
657<pre> 727<pre>
658 require "lanes" 728 local lanes = require "lanes"
729 lanes.configure( 1)
659 730
660 local linda= lanes.linda() 731 local linda= lanes.linda()
661 732
@@ -991,11 +1062,37 @@ its actual value.
991 1062
992<p> 1063<p>
993 1064
1065 Nov-2011
1066 <ul>
1067 <li>process exit change: close everything at GC when main state closes, not when atexit() handlers are processed</li>
1068 <li>Lua 5.2-style module:</li>
1069 <ul>
1070 <li>module() is no longer used to implement lanes.lua</li>
1071 <li>a global "lanes" variable is no longer created when the module is required</li>
1072 <li>the Lanes module table is returned instead</li>
1073 </ul>
1074 <li>Lanes must be initialized before used:</li>
1075 <ul>
1076 <li>the first occurence of 'require "lanes"' produces a minimal interface that only contains a configure() function</li>
1077 <li>the remainder of the interface is made available once this function is called</li>
1078 <li>subsequent calls to configure() do nothing</li>
1079 <li>configure() controls the number of keeper states and the startup of timers</li>
1080 </ul>
1081 <li>* LuaJIT 2 compatibility</li>
1082 <ul>
1083 <li>non-Lua functions are no longer copied by creating a C closure from a C pointer, but through 2-way lookup tables</li>
1084 <li>this means that if a lane function body pulls non-Lua functions, the lane generator description must contain the list of libraries and modules that exports them</li>
1085 <li>introduces a change in configuration .globals management: contents are copied *after* std libs are loaded</li>
1086 <li>new .required configuration entry to list modules that must be require()'ed before lane body is transferred</li>
1087 </ul>
1088 <li>lane:cancel() wakes up waiting lindas like what is done at lane shutdown</li>
1089 </ul>
1090
994 Mar-2011 (not yet versioned) 1091 Mar-2011 (not yet versioned)
995 <ul> 1092 <ul>
996 <li>linda honors __tostring and __concat</li> 1093 <li>linda honors __tostring and __concat</li>
997 <li>new accessor linda:keys(), to retrieve the list of keys with pending data inside a linda</li> 1094 <li>new accessor linda:count(), to get info about data stored inside a linda.</li>
998 <li>new lanes options packagepath and packagecpath, in case one needs to set them differently than the default</li> 1095 <li>new lanes options packagepath and packagecpath, in case one needs to set them differently than the default.</li>
999 </ul> 1096 </ul>
1000 1097
1001 Mar-2011 (2.1.0) 1098 Mar-2011 (2.1.0)