lua-users home
lua-l archive

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


Chris Marrin wrote:
 > Why not just point the userdata at a memory block that you allocate and
then pass that to the other thread? Since you allocate it, you can be sure its address will not be changed by Lua, even if the userdata pointing at it moves around.

You mean use a lightuserdata.

That is my current approach, but I was contemplating using Lua-allocated memory if it is safe to assume constancy of userdata.

given this from Roberto :

"We have no intention of
allowing userdata addresses to change during GC. Unlike strings, which
are an internal data in Lua, the only purpose of userdata is to be used
by C code, which prefer that things stay where they are :)"

I will now happily pass full userdata to a background thread (IOCP on Windows, fyi).

Adrian