lua-users home
lua-l archive

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


Benoit Germain wrote:

the result of the execution with printf() added in luaopen_xbdm and luaxbdm_gc:


lua LanesBug.wlua
luaopen_xbdm: threadId = 4596
luaopen_xbdm: threadId = 1836
luaxbdm_gc: userdata threadId = 1836, current thread id = 4596
luaxbdm_gc: userdata threadId = 4596, current thread id = 4596

the string issued by luaL_error doesn't reach the lane's join() return values.

Also, maybe not directly related, but bear in mind that if your threads join an apartment (an STA in your case) then your thread must pump messages.
You might want to try to join the MTA (COINIT_MULTITHREADED)

The fact is, I am using IUP, and it initializes itself with APARTMENTTHREADED. I wouldn't want to get a different initialisation model depending on the order the modules are required. And maybe IUP already takes care of all the necessary pumping :-)


Ah, since it is a GUI toolkit, I bet it does pump messages, so we're good.

I think we'll need Asko's help on this one, but from looking at Lanes sources, I think that when you join a lane, the thread that called join will be the one that calls the __gc methods. It seems that if the lane gets collected while running, it will be marked as "self destruct". In that case it seems that it will be the one in charge to call __gc handlers.

Now that I think of it, it seems quite logical. If you join a lane, you'll get its results back, so the lua_State in which it is running can't be closed yet. If let the lane loose, it will be in charge of cleanup.

Regards,
Ignacio