aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lanes.c59
-rw-r--r--src/lanes.lua5
2 files changed, 26 insertions, 38 deletions
diff --git a/src/lanes.c b/src/lanes.c
index ba9e59a..2b90caf 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -1845,21 +1845,17 @@ LUAG_FUNC( wakeup_conv )
1845/*---=== Module linkage ===--- 1845/*---=== Module linkage ===---
1846*/ 1846*/
1847 1847
1848#define REG_FUNC( name ) \ 1848static const struct luaL_reg lanes_functions [] = {
1849 lua_pushcfunction( L, LG_##name ); \ 1849 {"linda_id", LG_linda_id},
1850 lua_setglobal( L, #name ) 1850 {"thread_status", LG_thread_status},
1851 1851 {"thread_join", LG_thread_join},
1852#define REG_FUNC2( name, val ) \ 1852 {"thread_cancel", LG_thread_cancel},
1853 lua_pushcfunction( L, val ); \ 1853 {"now_secs", LG_now_secs},
1854 lua_setglobal( L, #name ) 1854 {"wakeup_conv", LG_wakeup_conv},
1855 1855 {"_single", LG__single},
1856#define REG_STR2( name, val ) \ 1856 {"_deep_userdata", luaG_deep_userdata},
1857 lua_pushstring( L, val ); \ 1857 {NULL, NULL}
1858 lua_setglobal( L, #name ) 1858};
1859
1860#define REG_INT2( name, val ) \
1861 lua_pushinteger( L, val ); \
1862 lua_setglobal( L, #name )
1863 1859
1864/* 1860/*
1865* One-time initializations 1861* One-time initializations
@@ -1996,9 +1992,9 @@ __declspec(dllexport)
1996#endif 1992#endif
1997 assert( timer_deep != 0 ); 1993 assert( timer_deep != 0 );
1998 1994
1999 // Linda identity function 1995 // Create main module interface table
2000 // 1996 lua_newtable(L);
2001 REG_FUNC( linda_id ); 1997 luaL_register(L, NULL, lanes_functions);
2002 1998
2003 // metatable for threads 1999 // metatable for threads
2004 // 2000 //
@@ -2007,29 +2003,22 @@ __declspec(dllexport)
2007 lua_setfield( L, -2, "__gc" ); 2003 lua_setfield( L, -2, "__gc" );
2008 2004
2009 lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param 2005 lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param
2010 lua_setglobal( L, "thread_new" ); 2006 lua_setfield(L, -2, "thread_new");
2011
2012 REG_FUNC( thread_status );
2013 REG_FUNC( thread_join );
2014 REG_FUNC( thread_cancel );
2015
2016 REG_STR2( _version, VERSION );
2017 REG_FUNC( _single );
2018
2019 REG_FUNC2( _deep_userdata, luaG_deep_userdata );
2020
2021 REG_FUNC( now_secs );
2022 REG_FUNC( wakeup_conv );
2023 2007
2024 luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep ); 2008 luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep );
2025 lua_setglobal( L, "timer_gateway" ); 2009 lua_setfield(L, -2, "timer_gateway");
2026 2010
2027 REG_INT2( max_prio, THREAD_PRIO_MAX ); 2011 lua_pushstring(L, VERSION);
2012 lua_setfield(L, -2, "_version");
2013
2014 lua_pushinteger(L, THREAD_PRIO_MAX);
2015 lua_setfield(L, -2, "max_prio");
2028 2016
2029 lua_pushlightuserdata( L, CANCEL_ERROR ); 2017 lua_pushlightuserdata( L, CANCEL_ERROR );
2030 lua_setglobal( L, "cancel_error" ); 2018 lua_setfield(L, -2, "cancel_error");
2031 2019
2032 return 0; 2020 // Return the local module table
2021 return 1;
2033} 2022}
2034 2023
2035 2024
diff --git a/src/lanes.lua b/src/lanes.lua
index 7ec8c76..42e946b 100644
--- a/src/lanes.lua
+++ b/src/lanes.lua
@@ -41,10 +41,9 @@ THE SOFTWARE.
41 41
42module( "lanes", package.seeall ) 42module( "lanes", package.seeall )
43 43
44require "lua51-lanes" 44local mm = require "lua51-lanes"
45assert( type(lanes)=="table" ) 45assert( type(mm)=="table" )
46 46
47local mm= lanes
48 47
49local linda_id= assert( mm.linda_id ) 48local linda_id= assert( mm.linda_id )
50 49