[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: attempt to yield across metamethod/C-call boundary
- From: "Aaron Saarela" <Aaron.Saarela@...>
- Date: Wed, 7 May 2008 18:21:14 -0400
I'm launching some Lua code from C++ using lua_pcall using Lua 5.1.3. My Lua
script is creating several coroutines and trying to deliver messages between
them. I'm getting the following error on yield however:
attempt to yield across metamethod/C-call boundary
Reading through the mailing list archive I discovered calling yield from a
script executed from lua_pcall isn't supported in standard Lua. I found the
coco patch that I thought would let me do what I'm after. The coco patch unit
tests all pass but I continue to get the above error.
Here's the flow of my application:
C++: Calls a Lua function that creates a coroutine to do some work.
Lua: Coroutine runs, but then needs to send a message back to C++ and wait
for a response. It calls a C++ function to 'send' the message and calls
coroutine.yield. It's at this point I get the above error.
C++: The message is handled, so it calls another Lua function to deliver the
Lua: The Lua function gets the response, and calls coroutine.resume for the
waiting coroutine, passing it the response.
I've done similar things in Python using a stackless tasklet. It seems I'm
missing a fundamental difference with Lua in this case.