From eb49247e9fbbf6edba5512a680e5389687f86786 Mon Sep 17 00:00:00 2001
From: Benoit Germain
- This document was revised on 30-Jan-13, and applies to version 3.5.0.
+ This document was revised on 12-Feb-13, and applies to version 3.5.1.
+ When Lanes is embedded, it is possible to statically initialize with
+
+ luaopen_lanes_embedded leaves the module table on the stack. lanes.configure() must still be called in order to use Lanes.
+
+ To embed Lanes, compile source files in you application. In any Lua state were you want to use Lanes, initialize it as follows:
+
+
+Embedding
+
+
+
+
+
+
+ extern void LANES_API luaopen_lanes_embedded( lua_State* L, lua_CFunction _luaopen_lanes);
+
+ If _luaopen_lanes is NULL, a default loader will simply attempt the equivalent of luaL_dofile( L, "lanes.lua").
+
+
+
+
+
+
+ #include "lanes.h"
+
+ int load_lanes_lua( lua_State* L)
+ {
+ // retrieve lanes.lua from wherever it is stored and return the result of its execution
+ // trivial example 1:
+ luaL_dofile( L, "lanes.lua");
+
+ // trivial example 2:
+ luaL_dostring( L, bin2c_lanes_lua);
+ }
+
+ void embed_lanes( lua_State* L)
+ {
+ // we need base libraries for Lanes for work
+ luaL_openlibs( L);
+ ...
+ // will attempt luaL_dofile( L, "lanes.lua");
+ luaopen_lanes_embedded( L, NULL);
+ lua_pop( L, 1);
+ // another example with a custom loader
+ luaopen_lanes_embedded( L, load_lanes_lua);
+ lua_pop( L, 1);
+
+ // a little test to make sure things work as expected
+ luaL_dostring( L, "local lanes = require 'lanes'.configure{with_timers = false}; local l = lanes.linda()");
+ }
+
- If the lane is still running after the timeout expired and force_kill is true, the OS thread running the lane is forcefully killed. This means no GC, and should generally be the last resort. + If the lane is still running after the timeout expired and force_kill is true, 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.
-- cgit v1.2.3-55-g6feb