lua-users home
lua-l archive

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

2008/12/2 Patrick Donnelly <>:
> On Mon, Dec 1, 2008 at 2:32 PM, Sam Roberts <> wrote:
>> On Mon, Dec 1, 2008 at 11:33 AM, Patrick Donnelly
>> <> wrote:
>>>> Looks legal to me, but I can see why you wonder. I don't see why you use the
>>>> thread lua_State instead of the parent lua_State.
>>> This is because the main lua_State thread is resuming threads and is
>>> not available to execute the callback function. I thought perhaps I
>> Now I'm confused again. We established you don't have OS threads.
> I want to emphasize that whenever I say "thread", I mean Lua threads.
> The main thread is resuming worker (script) threads. During the
> execution of one of these worker threads a callback may be executed.
> It would not be possible to handle the execution of that callback if
> the main thread (which happens to be Lua code) is waiting on
> coroutine.resume. That is what I meant (sorry for the confusion).

Why isn't that possible? It doesn't matter that there is a running
coroutine on the thread stack. Once you get control in C all threads
are *paused* and you can use all their stacks as you want, as long as
you can get a pointer to their lua_State.