lua-users home
lua-l archive

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


On Mon, Jul 18, 2011 at 12:03, Doug Currie <doug.currie@gmail.com> wrote:
>
> On Jul 18, 2011, at 11:50 AM, James McKaskill wrote:
>
>> That only gets you half way there. The main thread won't be gc'ed but
>> it may not be ready (yielded or resumed another coroutine). The only
>> method that is guaranteed to work is to create a thread for each
>> callback, but that seems a bit exuberant. I'm not sure how much
>> overhead this will entail without some testing. If its too much a
>> thread pool might be the way to go.
>
> The thread used by the callback does not need to be "ready" as long as the callback is well behaved (which seems necessary in any case). See:
>
> http://lua-users.org/lists/lua-l/2010-02/msg00447.html
>
> and the follow-up.

Interesting I will have to play with that. IIRC luajit doesn't allow
this and has a guard against it. I hit as I had a library that was
doing a lua_pcall on a state that was currently yielded and was
subsequently crashing.

lj_api.c:1008
  api_check(L, L->status == 0 || L->status == LUA_ERRERR);