lua-users home
lua-l archive

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


I think if we found a way to do this outside the hooks it would lead us to fixing the hook code and vice versa. At this point it seems to me no one knows the exact cause of problems during hook yields. All the yield function itself is doing is setting some flags and such. If this fails to work in a hook it will fail everywhere else as I can't see why any other location inside the main VM loop would be any better than the hook. 

AB

 -----Original Message-----
From: 	Nick Trout [mailto:nick@rockstarvancouver.com] 
Sent:	Thursday, July 10, 2003 7:12 PM
To:	Lua list
Subject:	RE: Implicit yielding in lua 5



> > 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