lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



So, which platform do you use? In case you are embedding LuaJIT,
are you sure you called luaopen_coco(), too? Or are you using
lua_newthread() anywhere else (lua_newcthread() is required)?

if lcoco.c is compiled with  COCO_USE_FIBERS then replacing :

CODE --------------
#define COCO_NEW(OL, NL, cstacksize, mainfunc) \
 if (GetCurrentFiber() == NULL) ConvertThreadToFiber(NULL); \
 if ((L2COCO(NL)->fib = CreateFiber(cstacksize, mainfunc, NL)) == NULL) \
   luaD_throw(OL, LUA_ERRMEM);
CODE --------------

with something like this :

CODE --------------
#if defined(LUA_BUILD_AS_DLL)
 static LPVOID main_fiber = NULL; // single threaded only i think
#else
 // so COCO_NEW works for single and MultiThreaded progs in static builds
 _declspec(thread) static LPVOID main_fiber = NULL;
#endif

#define COCO_NEW(OL, NL, cstacksize, mainfunc) \
 if (main_fiber == NULL) \
   ConvertThreadToFiber(NULL), main_fiber=GetCurrentFiber(); \
 if ((L2COCO(NL)->fib = CreateFiber(cstacksize, mainfunc, NL)) == NULL) \
   luaD_throw(OL, LUA_ERRMEM);
CODE --------------

could help.

GetCurrentFiber() never returns NULL so ConvertThreadToFiber() is never called.

Hope this helps.

Jan Reijnen