Re: lua script yield and resume in C Function
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: lua script yield and resume in C Function
- From: Jamie Webb <j@...>
- Date: 2004年7月29日 13:47:24 +0100
On Thu, Jul 29, 2004 at 12:21:19PM +0800, Yan Liang wrote:
> Hello, everyone!
> I am integrating Lua to my application, a game. I need stop the
> script running at some point, and resume at some time. I try to call
> "lua_yield" in MessageBox() C function,but get an error "attempt do
> yield across metamethod/C-call boundary".
That means that there is a C function or metamethod somewhere higher
up in your stack, e.g. you called the code you give using lua_call(),
or it's part of a function run with table.foreach, or it's part of an
__index metamethod...
In these situations, the Lua and C stacks are intertwined, and
yielding would have to involve forking the C stack, which is ugly and
non-portable, so Lua doesn't support it.
Unfortunately, this means you'll have to rearrange your program to
avoid this problem, or move to a C-level threading system.
-- Jamie Webb