[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Yielding across lua_load
- From: "Soni L." <fakedme@...>
- Date: Sun, 11 Oct 2015 00:07:09 -0300
On 10/10/15 11:51 PM, Tim Hill wrote:
On Oct 10, 2015, at 6:57 AM, Christian N. <email@example.com
On 2015-10-08 19:48 +0200, Soni L. wrote:
I don't think that would be possible, as yielding would jump outside
lua_load using longjmp, losing any information lua_load has stored on
the C stack (probably even leaking memory). However, using something
like the C++ library Boost.Context or Boost.Coroutine, a workaround
might maybe be possible as these libraries provide a way to sort of
save the C stack.
More to the point is why the original OP feels yielding during
lua_load() is necessary.
You can't yield during string.gsub callback either, but that's not relevant.
I actually do have an use for yielding during lua_load() and it has to
do with a Minecraft mod called OpenComputers. I can't remember what it
was because it happened a while ago but it did stop me from finishing
what I was doing.
It's also useful for JIT-tracing to Lua. (easier to reset/use as you
don't have to worry about state as much) Especially so when combined
with a 3rd party cooperative multitasking library. (you wouldn't be able
to keep the other threads going unless you yielded, which would kill the
load() and possibly the whole thread as well, because it would error)
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.