lua-users home
lua-l archive

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



> > Let's suppose I would want to yield every N instructions or a line
of
> code.
> > Yielding from hooks, as I had pointed out, is not a viable option.
> > However, let's suppose that the hook function instead of direct
> > yielding sets the > flag in lua_State, say, kfWantToYield.
> > Is there any place in Lua main VM that would be safe/suitable
> > for calling lua_yield?

We seem to be thinking along similar lines. I was thinking that the hook
callback function could return what the client wanted Lua to do next.
Possible return values would be "continue", "yield", "stop again in x
instructions". Lua would then perform the required action when
appropriate. This avoids trying to yield when the callstack is in the
client application.

> But it won't guarantee anything, because the program might be
something
> like this (possibly less exaggerated):

Not sure how you'd deal with time consuming client functions. That's
really an application specific problem.

--nick