lua-users home
lua-l archive

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


On Monday 31 May 2004 19:06, Mike Pall wrote:
> Hi,
>
> D Burgess wrote:
> > With one hook, could the hook could determine which thread caused
> > the hook to be invoked?
>
> A hook is always called within the thread that caused the invocation.
>
> So this is no problem for C code, since lua_State is passed to every
> call (and this just happens to be the thread handle). But I think there
> is no way to push this handle to the stack, so you cannot operate on
> it with lua functions (e.g. to store it in a table). I guess we need to add
> lua_pushthread()?

You could save the Lua thread value in the registry when you first create it, 
keyed on the state pointer.

> I see no way to get at the current thread from within Lua code. I've
> proposed coroutine.current() and an extension to debug.getinfo() to
> allow for that. See my previous message on this list.

And given the above you could easily implement this yourself.

-- Jamie Webb