From eb49247e9fbbf6edba5512a680e5389687f86786 Mon Sep 17 00:00:00 2001 From: Benoit Germain Date: Wed, 13 Feb 2013 20:30:04 +0100 Subject: version 3.5.1 * new lanes.h header and API call luaopen_lanes_embedded() for embedders * "lanes.core" is an acceptable library in the generator libs argument * library "*" wildcard also opens lanes.core * tweaked code for Xbox 360 build --- index.html | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 8b21a97..89710ab 100644 --- a/index.html +++ b/index.html @@ -37,7 +37,8 @@

Description · Supported systems · - Building and Installing + Building and Installing · + Embedding

@@ -69,7 +70,7 @@

- 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.

@@ -164,6 +165,65 @@ + +
+

Embedding

+

+ When Lanes is embedded, it is possible to statically initialize with +

+ + + + +
+
	extern void LANES_API luaopen_lanes_embedded( lua_State* L, lua_CFunction _luaopen_lanes);
+
+

+ luaopen_lanes_embedded leaves the module table on the stack. lanes.configure() must still be called in order to use Lanes. +
+ If _luaopen_lanes is NULL, a default loader will simply attempt the equivalent of luaL_dofile( L, "lanes.lua"). +

+ +

+ To embed Lanes, compile source files in you application. In any Lua state were you want to use Lanes, initialize it as follows: +

+ +

+ + + + +
+
	#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()");
+
	}
+
+

+
@@ -438,7 +498,7 @@ - All standard libraries (including those specific to LuaJIT and not listed above). This must be used alone. + All standard libraries (including those specific to LuaJIT and not listed above), as well as lanes.core. This must be used alone. @@ -765,7 +825,7 @@

- 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