diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2012-02-18 14:08:52 +0100 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2012-02-18 14:08:52 +0100 |
commit | 076344633e7b2525cf48005f84f3935f324b60bf (patch) | |
tree | 2a013da0ba2cd4a9f7eaf073a5ba128723f13154 /docs | |
parent | b4582dd0bb65a916de7fa9612880b75a17c7ae7f (diff) | |
download | lanes-076344633e7b2525cf48005f84f3935f324b60bf.tar.gz lanes-076344633e7b2525cf48005f84f3935f324b60bf.tar.bz2 lanes-076344633e7b2525cf48005f84f3935f324b60bf.zip |
* changed lanes.configure signature to receive a table instead of individual parameters
* added support for an on_state_create callback called to load custom functions in a state in addition to the base libraries
Diffstat (limited to 'docs')
-rw-r--r-- | docs/index.html | 104 |
1 files changed, 64 insertions, 40 deletions
diff --git a/docs/index.html b/docs/index.html index e24b172..72e91ba 100644 --- a/docs/index.html +++ b/docs/index.html | |||
@@ -56,7 +56,7 @@ | |||
56 | 56 | ||
57 | <p><br/><font size="-1"><i>Copyright © 2007-12 Asko Kauppi, Benoit Germain. All rights reserved.</i> | 57 | <p><br/><font size="-1"><i>Copyright © 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 5-Nov-11, and applies to version 3.0-beta. | 59 | </p><p>This document was revised on 17-Feb-11, and applies to version 3.1.0 |
60 | </font></p> | 60 | </font></p> |
61 | 61 | ||
62 | </center> | 62 | </center> |
@@ -173,8 +173,7 @@ Or use <A HREF="http://www.luarocks.org" TARGET="_blank">Lua Rocks</A> package m | |||
173 | <tr> | 173 | <tr> |
174 | <td> | 174 | <td> |
175 | <pre> | 175 | <pre> |
176 | local lanes = require "lanes" | 176 | local lanes = require "lanes".configure() |
177 | lanes.configure( 1) | ||
178 | </pre> | 177 | </pre> |
179 | </table> | 178 | </table> |
180 | 179 | ||
@@ -182,11 +181,11 @@ Or use <A HREF="http://www.luarocks.org" TARGET="_blank">Lua Rocks</A> package m | |||
182 | Starting with version 3.0-beta, requiring the module follows Lua 5.2 rules: | 181 | 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 | 182 | the module is not available under the global name "lanes", but has to be accessed |
184 | through require's return value. | 183 | through require's return value. |
185 | After lanes is required, it is necessary to call lanes.configure(), which is the | 184 | After lanes is required, it is necessary to call <tt>lanes.configure()</tt>, which is the |
186 | only function exposed by the module at this point. Calling configure() will | 185 | only function exposed by the module at this point. Calling <tt>configure()</tt> will |
187 | perform one-time initializations and make the rest of the API available. | 186 | 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 | 187 | At the same time, <tt>configure()</tt> itself will be replaced by another function that |
189 | raises an error if called with differing arguments. | 188 | raises an error if called again with differing arguments. |
190 | </p> | 189 | </p> |
191 | 190 | ||
192 | <p> | 191 | <p> |
@@ -194,19 +193,39 @@ Or use <A HREF="http://www.luarocks.org" TARGET="_blank">Lua Rocks</A> package m | |||
194 | <tr> | 193 | <tr> |
195 | <td> | 194 | <td> |
196 | <code> | 195 | <code> |
197 | lanes.configure( [nb_keepers] [, "NO_TIMERS"]) | 196 | lanes.configure( [opt_tbl]) |
198 | </code> | 197 | </code> |
199 | </table> | 198 | </table> |
200 | </p> | 199 | </p> |
201 | <p> | 200 | <p> |
202 | <tt>lanes.configure</tt> accepts 2 arguments. The first one controls the number | 201 | <tt>lanes.configure</tt> accepts an optional options table as sole argument. |
203 | of keeper states used internally by lindas to transfer data between lanes. (see below). | 202 | <table> |
204 | Default is 1. | 203 | <tr valign=top><td width=40></td><td> |
205 | </p> | 204 | <code>.nb_keepers</code> <br/><nobr>N</nobr></td><td width=40></td> |
206 | <p>If the second argument is equal to <tt>"NO_TIMERS"</tt>, Lanes doesn't start the timer service, | 205 | <td> |
206 | Controls the number of keeper states used internally by lindas to transfer data between lanes. (see below). Default is 1. | ||
207 | </td></tr> | ||
208 | |||
209 | <tr valign=top><td/><td> | ||
210 | <code>.with_timers</code> <br/>nil/false/anything</td><td/> | ||
211 | <td> | ||
212 | If equal to <tt>false</tt>, Lanes doesn't start the timer service, | ||
207 | and the associated API will be absent from the interface (see below). | 213 | and the associated API will be absent from the interface (see below). |
208 | </p> | 214 | Any other value (including <tt>nil</tt>), starts the timer service. |
209 | <h2 id="creation">Creation</h2> | 215 | </td></tr> |
216 | |||
217 | <tr valign="top"> | ||
218 | <td/> | ||
219 | <td> | ||
220 | <code>.on_create_state</code> <br/>C function/nil | ||
221 | </td><td/> | ||
222 | <td> | ||
223 | If provided, will be called in every created Lua state (keepers and lanes) right after it is created, and *before* any library is loaded. | ||
224 | That way, all C functions it loads in the state can be added to the function lookup database. | ||
225 | </td> | ||
226 | </tr> | ||
227 | </table> | ||
228 | <h2 id="creation">Creation</h2> | ||
210 | 229 | ||
211 | <p>The following sample shows preparing a function for parallel calling, and | 230 | <p>The following sample shows preparing a function for parallel calling, and |
212 | calling it with varying arguments. Each of the two results is calculated in | 231 | calling it with varying arguments. Each of the two results is calculated in |
@@ -217,7 +236,7 @@ joins the threads, waiting for any results not already there. | |||
217 | <table border=1 bgcolor="#FFFFE0" width=500><tr><td> | 236 | <table border=1 bgcolor="#FFFFE0" width=500><tr><td> |
218 | <pre> | 237 | <pre> |
219 | local lanes = require "lanes" | 238 | local lanes = require "lanes" |
220 | lanes.configure( 1) | 239 | lanes.configure() |
221 | 240 | ||
222 | f= lanes.gen( function(n) return 2*n end ) | 241 | f= lanes.gen( function(n) return 2*n end ) |
223 | a= f(1) | 242 | a= f(1) |
@@ -240,8 +259,8 @@ joins the threads, waiting for any results not already there. | |||
240 | but the particular arguments may vary. Only calling the generator function | 259 | but the particular arguments may vary. Only calling the generator function |
241 | actually launches a lane, and provides a handle for controlling it. | 260 | actually launches a lane, and provides a handle for controlling it. |
242 | Alternatively, <tt>lane_func</tt> may be a string, in which case it will be compiled | 261 | Alternatively, <tt>lane_func</tt> may be a string, in which case it will be compiled |
243 | in the lane. This is to be able to launch lanes whith LuaJIT, | 262 | in the lane. This was to be able to launch lanes with older versions of LuaJIT, |
244 | which does not support lua_dump, used internally to transfer functions to the lane. | 263 | which didn't not support lua_dump, used internally to transfer functions to the lane. |
245 | <!-- | 264 | <!-- |
246 | </p> | 265 | </p> |
247 | <p>This prepares <tt>lane_func</tt> to be called in parallel. It does not yet start | 266 | <p>This prepares <tt>lane_func</tt> to be called in parallel. It does not yet start |
@@ -257,19 +276,21 @@ also in the new lanes. | |||
257 | <code>libs_str</code> defines the standard libraries made available to the | 276 | <code>libs_str</code> defines the standard libraries made available to the |
258 | new Lua state: | 277 | new Lua state: |
259 | <table> | 278 | <table> |
260 | <tr><td/><td>(nothing)</td><td>no standard libraries (default)</td></tr> | 279 | <tr><td width=40></td><td>(nothing)</td><td width=40></td><td>no standard libraries (default)</td></tr> |
261 | <tr><td width=40><td><tt>"base"</tt> or <tt>""</tt></td> | 280 | <tr><td/> |
262 | <td>root level names, <tt>print</tt>, <tt>assert</tt>, <tt>unpack</tt> etc.</td></tr> | 281 | <td><tt>"base"</tt> or <tt>""</tt></td><td/> |
263 | <tr><td/><td><tt>"coroutine"</tt></td><td><tt>coroutine.*</tt> namespace <font size="-1">(part of base in Lua 5.1)</font></td></tr> | 282 | <td>root level names, <tt>print</tt>, <tt>assert</tt>, <tt>unpack</tt> etc.</td> |
264 | <tr><td/><td><tt>"debug"</tt></td><td><tt>debug.*</tt> namespace</td></tr> | 283 | </tr> |
265 | <tr><td/><td><tt>"io"</tt></td><td><tt>io.*</tt> namespace</td></tr> | 284 | <tr><td/><td><tt>"coroutine"</tt></td><td/><td><tt>coroutine.*</tt> namespace <font size="-1">(part of base in Lua 5.1)</font></td></tr> |
266 | <tr><td/><td><tt>"math"</tt></td><td><tt>math.*</tt> namespace</td></tr> | 285 | <tr><td/><td><tt>"debug"</tt></td><td/><td><tt>debug.*</tt> namespace</td></tr> |
267 | <tr><td/><td><tt>"os"</tt></td><td><tt>os.*</tt> namespace</td></tr> | 286 | <tr><td/><td><tt>"io"</tt></td><td/><td><tt>io.*</tt> namespace</td></tr> |
268 | <tr><td/><td><tt>"package"</tt></td><td><tt>package.*</tt> namespace and <tt>require</tt></td></tr> | 287 | <tr><td/><td><tt>"math"</tt></td><td/><td><tt>math.*</tt> namespace</td></tr> |
269 | <tr><td/><td><tt>"string"</tt></td><td><tt>string.*</tt> namespace</td></tr> | 288 | <tr><td/><td><tt>"os"</tt></td><td/><td><tt>os.*</tt> namespace</td></tr> |
270 | <tr><td/><td><tt>"table"</tt></td><td><tt>table.*</tt> namespace</td></tr> | 289 | <tr><td/><td><tt>"package"</tt></td><td/><td><tt>package.*</tt> namespace and <tt>require</tt></td></tr> |
290 | <tr><td/><td><tt>"string"</tt></td><td/><td><tt>string.*</tt> namespace</td></tr> | ||
291 | <tr><td/><td><tt>"table"</tt></td><td/><td><tt>table.*</tt> namespace</td></tr> | ||
271 | <br/> | 292 | <br/> |
272 | <tr><td/><td><tt>"*"</tt></td><td>all standard libraries</td></tr> | 293 | <tr><td/><td><tt>"*"</tt></td><td/><td>all standard libraries</td></tr> |
273 | </table> | 294 | </table> |
274 | 295 | ||
275 | </p><p> | 296 | </p><p> |
@@ -281,9 +302,9 @@ also in the new lanes. | |||
281 | lanes are run: | 302 | lanes are run: |
282 | </p><p> | 303 | </p><p> |
283 | <table> | 304 | <table> |
284 | <tr valign=top><td/><td> | 305 | <tr valign=top><td width=40></td><td> |
285 | <code>.cancelstep</code> <br/><nobr>N / true</nobr></td> | 306 | <code>.cancelstep</code> <br/><nobr>N / true</nobr></td> |
286 | <td> | 307 | <td width=40></td><td> |
287 | By default, lanes are only cancellable when they <u>enter</u> a pending | 308 | By default, lanes are only cancellable when they <u>enter</u> a pending |
288 | <tt>:receive()</tt> or <tt>:send()</tt> call. | 309 | <tt>:receive()</tt> or <tt>:send()</tt> call. |
289 | With this option, one can set cancellation check to occur every <tt>N</tt> | 310 | With this option, one can set cancellation check to occur every <tt>N</tt> |
@@ -292,7 +313,7 @@ also in the new lanes. | |||
292 | </td></tr> | 313 | </td></tr> |
293 | 314 | ||
294 | <tr valign=top><td/><td> | 315 | <tr valign=top><td/><td> |
295 | <code>.globals</code> <br/>globals_tbl</td> | 316 | <code>.globals</code> <br/>globals_tbl</td><td/> |
296 | <td> | 317 | <td> |
297 | Sets the globals table for the launched threads. This can be used for giving | 318 | Sets the globals table for the launched threads. This can be used for giving |
298 | them constants. | 319 | them constants. |
@@ -305,21 +326,18 @@ also in the new lanes. | |||
305 | <td/> | 326 | <td/> |
306 | <td> | 327 | <td> |
307 | <code>.required</code> <br/>modules_tbl | 328 | <code>.required</code> <br/>modules_tbl |
308 | </td> | 329 | </td><td/> |
309 | <td> | 330 | <td> |
310 | Lists modules that have to be required in order to be able to trasnfer | 331 | 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 | 332 | 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 | 333 | 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> | 334 | 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. | 335 | 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> | 336 | </td> |
319 | </tr> | 337 | </tr> |
320 | 338 | ||
321 | <tr valign=top><td width=40><td> | 339 | <tr valign=top><td width=40><td> |
322 | <code>.priority</code> <br/><nobr>-2..+2</nobr></td> | 340 | <code>.priority</code> <br/><nobr>-2..+2</nobr></td><td/> |
323 | <td>The priority of lanes generated. -2 is lowest, +2 is highest. | 341 | <td>The priority of lanes generated. -2 is lowest, +2 is highest. |
324 | <br> | 342 | <br> |
325 | Implementation and dependability of priorities varies | 343 | Implementation and dependability of priorities varies |
@@ -331,7 +349,7 @@ also in the new lanes. | |||
331 | <td> | 349 | <td> |
332 | <code>.package</code><br/> | 350 | <code>.package</code><br/> |
333 | </td> | 351 | </td> |
334 | <td> | 352 | <td><td/> |
335 | <code>package</code> contents overrides, if needed. | 353 | <code>package</code> contents overrides, if needed. |
336 | Specifying it when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error. | 354 | Specifying it when <code>libs_str</code> doesn't cause the <code>package</code> library to be loaded will generate an error. |
337 | If not specified, the created lane will receive the current values of <tt>package</tt>. Only path, cpath, preload and loaders are transfered. | 355 | If not specified, the created lane will receive the current values of <tt>package</tt>. Only path, cpath, preload and loaders are transfered. |
@@ -704,7 +722,7 @@ events to a common Linda, but... :).</font> | |||
704 | <code>= lanes.timer( linda_h, key, date_tbl|first_secs [,period_secs] )</code> | 722 | <code>= lanes.timer( linda_h, key, date_tbl|first_secs [,period_secs] )</code> |
705 | </table> | 723 | </table> |
706 | 724 | ||
707 | <p> | 725 | <p> |
708 | Timers are implemented as a lane. They can be disabled by passing <tt>"NO_TIMERS"</tt> | 726 | Timers are implemented as a lane. They can be disabled by passing <tt>"NO_TIMERS"</tt> |
709 | to <tt>lanes.configure()</tt>. | 727 | to <tt>lanes.configure()</tt>. |
710 | </p> | 728 | </p> |
@@ -1060,6 +1078,12 @@ its actual value. | |||
1060 | <h2 id="changes">Change log</h2> | 1078 | <h2 id="changes">Change log</h2> |
1061 | 1079 | ||
1062 | <p> | 1080 | <p> |
1081 | Feb-2012 | ||
1082 | <ul> | ||
1083 | <li>Added support for an on_state_create callback invoked on a pristine Lua state created by Lanes.</li> | ||
1084 | <li>This required a change in the <tt>lanes.configure()</tt> signature, hence the minor version bump.</li> | ||
1085 | </ul> | ||
1086 | |||
1063 | 1087 | ||
1064 | Nov-2011 | 1088 | Nov-2011 |
1065 | <ul> | 1089 | <ul> |