lua-users home
lua-l archive

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

On 10-Feb-05, at 6:41 PM, Scott Graham wrote:

Can someone explain how coroutine.resume differs from lua_resume? Is there a way to do what I'm trying to do, or must I always use the first version?

lua_resume's first argument is *the thread itself*. So you need something like this:

  lua_State *L1;
  lua_getglobal(L, "my_coroutine");
  L1 = lua_tothread(L, -1); /* get the thread */
  /* make sure L1 is not NULL */
  status = lua_resume(L1, 0); /* resume the thread */
  /* make sure status is 0 */
  lua_pop(L, 1);

if you need to pass arguments or receive results, see lua_xmove()