#include #include #include #include using namespace std; extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } static void output_stack_size(lua_State *L){ int n = lua_gettop(L); cout<<"stack size is "< 2){ max_state_num = atoi(argv[1]); max_coroutine_num = atoi(argv[2]); } const char *filename = "../../test/test_coroutine/test.lua"; vector states; for(int i = 0; i < max_state_num; i++){ lua_State *L = luaL_newstate(); luaL_openlibs(L); luaL_dofile(L, filename); states.push_back(L); } vector> coroutines; for(auto state : states){ int i = 0; for(; i < max_coroutine_num; i++){ lua_State* l = lua_newthread(state); int ret = lua_checkstack(state, 1); if(ret != 1) printf("do not have enough space, ret is %d\n", ret); coroutines.push_back({l, state}); lua_getglobal(l, "test"); //cout<<"after getglobal, size = "<