From 076344633e7b2525cf48005f84f3935f324b60bf Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Sat, 18 Feb 2012 14:08:52 +0100 Subject: * 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 --- CHANGES | 4 ++ docs/index.html | 104 ++++++++++++++++++++++++++++------------------ src/keeper.c | 18 ++++---- src/keeper.h | 2 +- src/lanes.c | 66 +++++++++++++---------------- src/lanes.lua | 32 +++++++++----- src/tools.c | 81 +++++++++++++++++++++--------------- src/tools.h | 4 +- tests/appendud.lua | 2 +- tests/atexit.lua | 2 +- tests/atomic.lua | 2 +- tests/basic.lua | 2 +- tests/cyclic.lua | 2 +- tests/ehynes.lua | 2 +- tests/errhangtest.lua | 2 +- tests/error.lua | 2 +- tests/fibonacci.lua | 2 +- tests/fifo.lua | 2 +- tests/finalizer.lua | 2 +- tests/func_is_string.lua | 2 +- tests/hangtest.lua | 2 +- tests/irayo_closure.lua | 2 +- tests/irayo_recursive.lua | 2 +- tests/keeper.lua | 2 +- tests/launchtest.lua | 2 +- tests/linda_perf.lua | 2 +- tests/objects.lua | 2 +- tests/perftest.lua | 2 +- tests/recursive.lua | 2 +- tests/require.lua | 2 +- tests/timer.lua | 2 +- 31 files changed, 199 insertions(+), 158 deletions(-) diff --git a/CHANGES b/CHANGES index a6ddcfc..b2fe499 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,10 @@ CHANGES: CHANGE X: +CHANGE 35 BGe 17-Feb-2012 + * 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 + CHANGE 34 BGe 14-Nov-2011 * removed packagepath and packagecpath options, replaced by a package table, whose fields path, cpath, loaders, preload are transfered * code cleanup to facilitate transition between WIN32 and PTHREAD impleentations 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 @@


Copyright © 2007-12 Asko Kauppi, Benoit Germain. All rights reserved.
Lua Lanes is published under the same MIT license as Lua 5.1. -

This document was revised on 5-Nov-11, and applies to version 3.0-beta. +

This document was revised on 17-Feb-11, and applies to version 3.1.0

@@ -173,8 +173,7 @@ Or use Lua Rocks package m
-          local lanes = require "lanes"
-          lanes.configure( 1)
+          local lanes = require "lanes".configure()
         
@@ -182,11 +181,11 @@ Or use Lua Rocks package m 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 require's return value. - After lanes is required, it is necessary to call lanes.configure(), which is the - only function exposed by the module at this point. Calling configure() will + After lanes is required, it is necessary to call lanes.configure(), which is the + only function exposed by the module at this point. Calling configure() will perform one-time initializations and make the rest of the API available. - At the same time, configure() itself will be replaced by another function that - raises an error if called with differing arguments. + At the same time, configure() itself will be replaced by another function that + raises an error if called again with differing arguments.

@@ -194,19 +193,39 @@ Or use Lua Rocks package m - lanes.configure( [nb_keepers] [, "NO_TIMERS"]) + lanes.configure( [opt_tbl])

- lanes.configure accepts 2 arguments. The first one controls the number - of keeper states used internally by lindas to transfer data between lanes. (see below). - Default is 1. -

-

If the second argument is equal to "NO_TIMERS", Lanes doesn't start the timer service, + lanes.configure accepts an optional options table as sole argument. + + + + + + + + + +
+ .nb_keepers
N
+ Controls the number of keeper states used internally by lindas to transfer data between lanes. (see below). Default is 1. +
+ .with_timers
nil/false/anything
+ + If equal to false, Lanes doesn't start the timer service, and the associated API will be absent from the interface (see below). -

-

Creation

+ Any other value (including nil), starts the timer service. +
+ + .on_create_state
C function/nil +
+ + If provided, will be called in every created Lua state (keepers and lanes) right after it is created, and *before* any library is loaded. + That way, all C functions it loads in the state can be added to the function lookup database. +
+

Creation

The following sample shows preparing a function for parallel calling, and 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.
   local lanes = require "lanes"
-  lanes.configure( 1)
+  lanes.configure()
 
   f= lanes.gen( function(n) return 2*n end )
   a= f(1)
@@ -240,8 +259,8 @@ joins the threads, waiting for any results not already there.
     but the particular arguments may vary. Only calling the generator function
     actually launches a lane, and provides a handle for controlling it.
     Alternatively, lane_func may be a string, in which case it will be compiled
-    in the lane. This is to be able to launch lanes whith LuaJIT,
-    which does not support lua_dump, used internally to transfer functions to the lane.
+    in the lane. This was to be able to launch lanes with older versions of LuaJIT,
+    which didn't not support lua_dump, used internally to transfer functions to the lane.