lua-users home
lua-l archive

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


Tobias Markmann wrote:
> > attempt to yield across metamethod/C-call boundary
> > stack traceback:
> > 	[C]: in function 'wait'
> I thought with the coro patch from luajit.org something like this is
> possible. So my question is: How to yield/resume the right way from C?

Three possible causes:
- Either you're attempting to yield from the main thread
  (this doesn't work, it must be a coroutine)
- or you're not using coroutine.resume/lua_resume() to run your
  coroutines
- or you're creating the coroutine with lua_newthread() from C.

Yielding across C frames only works if you create the coroutine
with a C stack. So either use coroutine.create/coroutine.wrap from
Lua or use lua_newcthread() (note the 'c') from C.

Your use of lua_yield() is perfectly fine in the context of Coco.
The docs are here: http://luajit.org/coco_api.html

--Mike