lua-users home
lua-l archive

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


Hi,

I'm building a multi-threaded application and all threads carry their own stat.
Now, I have to create an object to share data among those stats, named SelFIFO : this object is NEVER subject to be collected, mutex are handled at C side and slaves only get a C pointer to userdata.

My concern is "how can I insert this pointer to slave stats ?".

So, in the main thread, this object is created like that :

struct SelFIFO *q = (struct SelFIFO *)lua_newuserdata(L, sizeof(struct SelFIFO));
assert(q);
luaL_getmetatable(L, "SelFIFO");
lua_setmetatable(L, -2);
...

but, in the slave thread, I got only 'q' pointer.
How can I push it in slave's stat ?
How can I associate a "SelFIFO" to it ?

Thanks

Laurent

ps: full source code is https://github.com/destroyedlolo/Selene/blob/master/src/SelFIFO.c