lua-users home
lua-l archive

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


On Tue, Dec 2, 2008 at 10:30 AM, Jerome Vuarand
<jerome.vuarand@gmail.com> wrote:
> 2008/12/2 Patrick Donnelly <batrick.donnelly@gmail.com>:
>>
>> 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.

Indeed.
But make sure the stack manipulations are properly balanced and use
relative stack positions from the top. Otherwise you can get strange
behavior and/or memory leaks.

-- 
Dirk