aboutsummaryrefslogtreecommitdiff
path: root/src/keeper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/keeper.c')
-rw-r--r--src/keeper.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/keeper.c b/src/keeper.c
index 1f69d40..6f5bd95 100644
--- a/src/keeper.c
+++ b/src/keeper.c
@@ -78,7 +78,7 @@ static char const keeper_chunk[]=
78* unclosed, because it does not really matter. In production code, this 78* unclosed, because it does not really matter. In production code, this
79* function never fails. 79* function never fails.
80*/ 80*/
81char const *init_keepers( int const _nbKeepers) 81char const* init_keepers( int const _nbKeepers, lua_CFunction _on_state_create)
82{ 82{
83 int i; 83 int i;
84 assert( _nbKeepers >= 1); 84 assert( _nbKeepers >= 1);
@@ -87,10 +87,11 @@ char const *init_keepers( int const _nbKeepers)
87 for( i = 0; i < _nbKeepers; ++ i) 87 for( i = 0; i < _nbKeepers; ++ i)
88 { 88 {
89 89
90 // Initialize Keeper states with bare minimum of libs (those required 90 // Initialize Keeper states with bare minimum of libs (those required by 'keeper.lua')
91 // by 'keeper.lua') 91 //
92 // 92 // 'io' for debugging messages, 'package' because we need to require modules exporting idfuncs
93 lua_State *K = luaL_newstate(); 93 // the others because they export functions that we may store in a keeper for transfer between lanes
94 lua_State* K = luaG_newstate( "*", _on_state_create);
94 if (!K) 95 if (!K)
95 return "out of memory"; 96 return "out of memory";
96 97
@@ -100,11 +101,6 @@ char const *init_keepers( int const _nbKeepers)
100 lua_concat( K, 2); 101 lua_concat( K, 2);
101 lua_setglobal( K, "decoda_name"); 102 lua_setglobal( K, "decoda_name");
102 103
103 // 'io' for debugging messages, 'package' because we need to require modules exporting idfuncs
104 // the others because they export functions that we may store in a keeper for transfer between lanes
105 luaG_openlibs( K, "*");
106 serialize_require( K);
107
108 // Read in the preloaded chunk (and run it) 104 // Read in the preloaded chunk (and run it)
109 // 105 //
110 if( luaL_loadbuffer( K, keeper_chunk, sizeof(keeper_chunk), "@keeper.lua")) 106 if( luaL_loadbuffer( K, keeper_chunk, sizeof(keeper_chunk), "@keeper.lua"))
@@ -114,7 +110,7 @@ char const *init_keepers( int const _nbKeepers)
114 { 110 {
115 // LUA_ERRRUN / LUA_ERRMEM / LUA_ERRERR 111 // LUA_ERRRUN / LUA_ERRMEM / LUA_ERRERR
116 // 112 //
117 const char *err = lua_tostring(K, -1); 113 char const* err = lua_tostring( K, -1);
118 assert( err); 114 assert( err);
119 return err; 115 return err;
120 } 116 }