[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Manual timeslicing the VM.
- From: Mike Pall <mikelu-0604@...>
- Date: Wed, 26 Apr 2006 13:24:47 +0200
Hi,
David Jones wrote:
> On Aug 05, 2005, at 11:19, Mike Pall wrote:
> >So from C do a lua_newthread() and then lua_sethook() to install
> >your count hook. When the hook decides that the timeout is reached
> >it forces a yield for the coroutine with 'return lua_yield(L, 0)'.
>
> Doesn't this go wrong if the hook tries to yield when we were running a
> metamethod, or an iterator?
Yes, it would raise an error.
> If so, do you have a recommended workaround?
Use Coco. It allows you to yield from pretty much anywhere.
Note that hooks are turned off for __gc, so AFAIK the above
approach is safe.
Bye,
Mike