diff options
-rw-r--r-- | src/lanes.c | 59 | ||||
-rw-r--r-- | src/lanes.lua | 5 |
2 files changed, 26 insertions, 38 deletions
diff --git a/src/lanes.c b/src/lanes.c index 0873339..f4bef7b 100644 --- a/src/lanes.c +++ b/src/lanes.c | |||
@@ -1854,21 +1854,17 @@ LUAG_FUNC( wakeup_conv ) | |||
1854 | /*---=== Module linkage ===--- | 1854 | /*---=== Module linkage ===--- |
1855 | */ | 1855 | */ |
1856 | 1856 | ||
1857 | #define REG_FUNC( name ) \ | 1857 | static const struct luaL_reg lanes_functions [] = { |
1858 | lua_pushcfunction( L, LG_##name ); \ | 1858 | {"linda_id", LG_linda_id}, |
1859 | lua_setglobal( L, #name ) | 1859 | {"thread_status", LG_thread_status}, |
1860 | 1860 | {"thread_join", LG_thread_join}, | |
1861 | #define REG_FUNC2( name, val ) \ | 1861 | {"thread_cancel", LG_thread_cancel}, |
1862 | lua_pushcfunction( L, val ); \ | 1862 | {"now_secs", LG_now_secs}, |
1863 | lua_setglobal( L, #name ) | 1863 | {"wakeup_conv", LG_wakeup_conv}, |
1864 | 1864 | {"_single", LG__single}, | |
1865 | #define REG_STR2( name, val ) \ | 1865 | {"_deep_userdata", luaG_deep_userdata}, |
1866 | lua_pushstring( L, val ); \ | 1866 | {NULL, NULL} |
1867 | lua_setglobal( L, #name ) | 1867 | }; |
1868 | |||
1869 | #define REG_INT2( name, val ) \ | ||
1870 | lua_pushinteger( L, val ); \ | ||
1871 | lua_setglobal( L, #name ) | ||
1872 | 1868 | ||
1873 | /* | 1869 | /* |
1874 | * One-time initializations | 1870 | * One-time initializations |
@@ -2005,9 +2001,9 @@ __declspec(dllexport) | |||
2005 | #endif | 2001 | #endif |
2006 | assert( timer_deep != 0 ); | 2002 | assert( timer_deep != 0 ); |
2007 | 2003 | ||
2008 | // Linda identity function | 2004 | // Create main module interface table |
2009 | // | 2005 | lua_newtable(L); |
2010 | REG_FUNC( linda_id ); | 2006 | luaL_register(L, NULL, lanes_functions); |
2011 | 2007 | ||
2012 | // metatable for threads | 2008 | // metatable for threads |
2013 | // | 2009 | // |
@@ -2016,29 +2012,22 @@ __declspec(dllexport) | |||
2016 | lua_setfield( L, -2, "__gc" ); | 2012 | lua_setfield( L, -2, "__gc" ); |
2017 | 2013 | ||
2018 | lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param | 2014 | lua_pushcclosure( L, LG_thread_new, 1 ); // metatable as closure param |
2019 | lua_setglobal( L, "thread_new" ); | 2015 | lua_setfield(L, -2, "thread_new"); |
2020 | |||
2021 | REG_FUNC( thread_status ); | ||
2022 | REG_FUNC( thread_join ); | ||
2023 | REG_FUNC( thread_cancel ); | ||
2024 | |||
2025 | REG_STR2( _version, VERSION ); | ||
2026 | REG_FUNC( _single ); | ||
2027 | |||
2028 | REG_FUNC2( _deep_userdata, luaG_deep_userdata ); | ||
2029 | |||
2030 | REG_FUNC( now_secs ); | ||
2031 | REG_FUNC( wakeup_conv ); | ||
2032 | 2016 | ||
2033 | luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep ); | 2017 | luaG_push_proxy( L, LG_linda_id, (DEEP_PRELUDE *) timer_deep ); |
2034 | lua_setglobal( L, "timer_gateway" ); | 2018 | lua_setfield(L, -2, "timer_gateway"); |
2035 | 2019 | ||
2036 | REG_INT2( max_prio, THREAD_PRIO_MAX ); | 2020 | lua_pushstring(L, VERSION); |
2021 | lua_setfield(L, -2, "_version"); | ||
2022 | |||
2023 | lua_pushinteger(L, THREAD_PRIO_MAX); | ||
2024 | lua_setfield(L, -2, "max_prio"); | ||
2037 | 2025 | ||
2038 | lua_pushlightuserdata( L, CANCEL_ERROR ); | 2026 | lua_pushlightuserdata( L, CANCEL_ERROR ); |
2039 | lua_setglobal( L, "cancel_error" ); | 2027 | lua_setfield(L, -2, "cancel_error"); |
2040 | 2028 | ||
2041 | return 0; | 2029 | // Return the local module table |
2030 | return 1; | ||
2042 | } | 2031 | } |
2043 | 2032 | ||
2044 | 2033 | ||
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 | ||
42 | module( "lanes", package.seeall ) | 42 | module( "lanes", package.seeall ) |
43 | 43 | ||
44 | require "lua51-lanes" | 44 | local mm = require "lua51-lanes" |
45 | assert( type(lanes)=="table" ) | 45 | assert( type(mm)=="table" ) |
46 | 46 | ||
47 | local mm= lanes | ||
48 | 47 | ||
49 | local linda_id= assert( mm.linda_id ) | 48 | local linda_id= assert( mm.linda_id ) |
50 | 49 | ||