[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LUAI_EXTRASPACE and luai_userstateopen
- From: Oliver Schmidt <oschmidt_do_not_send_email_to_this_address@...>
- Date: Sat, 6 Mar 2010 11:37:04 +0100
Hi,
On Saturday 06 March 2010, Alexey Baskakov wrote:
> How to add custom per-thread data in Lua 5.2?
> But I need it to be very _fast_.
In Lua 5.1 there are the following macros in luaconf.h. With these macros you
can put extra data to any Lua state and it will be very fast. However you have
to compile your own Lua interpreter, so I'm not sure if this is what you are
looking for:
- LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
(the data goes just *before* the lua_State pointer).
- luai_userstate* allow user-specific actions on threads.
CHANGE them if you defined LUAI_EXTRASPACE and need to do something
extra when a thread is created/deleted/resumed/yielded.
luai_userstateopen(L) ((void)L)
luai_userstateclose(L) ((void)L)
luai_userstatethread(L,L1) ((void)L)
luai_userstatefree(L) ((void)L)
luai_userstateresume(L,n) ((void)L)
luai_userstateyield(L,n) ((void)L)
In Lua 5.2 these macros are not any longer in luaconf.h but are still in the
code: see llimits.h and lstate.c.
I hope that this mechanism will not vanish in the final Lua 5.2 version.
Best regards,
Oliver