- /* destroy the context */
- luaL_unref(lua_state,LUA_REGISTRYINDEX,context->ref );
- free(context);
- }
-}
-
-static void smx_ctx_lua_start(smx_context_t pcontext) {
- smx_ctx_lua_t context = (smx_ctx_lua_t)pcontext;
-
- makecontext(&context->uc, smx_ctx_sysv_wrapper, 0);
-
- INFO1("Starting '%s'",context->argv[0]);
-
- lua_getglobal(context->state,context->argv[0]);
- if(!lua_isfunction(context->state,-1)) {
- lua_pop(context->state,1);
- THROW1(arg_error,0,"The lua function %s does not seem to exist",context->argv[0]);
+ /* let the lua garbage collector reclaim the thread used for the coroutine */
+ luaL_unref(lua_state,LUA_REGISTRYINDEX,((smx_ctx_lua_t)context)->ref );