[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Manipulating a yielded thread from C
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Tue, 2 Dec 2008 10:30:28 +0100
2008/12/2 Patrick Donnelly <email@example.com>:
> On Mon, Dec 1, 2008 at 2:32 PM, Sam Roberts <firstname.lastname@example.org> wrote:
>> On Mon, Dec 1, 2008 at 11:33 AM, Patrick Donnelly
>> <email@example.com> 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.