lua-users home
lua-l archive

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


> There seems to be no public function in the API to determine 
> if a script has yielded or stopped naturally.

No, but lua_resume "returns" the arguments you passed to "yield", or the
return value of the thread (when it stops naturally). So, as long as you
follow some convention, it is easy to set them apart.


> I'm not clear on the argument handling stuff that's why it's 0 for now.

  LUA_API void lua_cobegin (lua_State *L, int nargs);

  nargs is the number of arguments you are passing to the start function
  (like "nargs" in lua_call).

  LUA_API int  lua_resume (lua_State *L, lua_State *co);
  'L' is the calling thread, 'co' is the co-routine you are activating.

  LUA_API int  lua_yield (lua_State *L, int nresults);
  'nresults' is the number of results (in the stack) that will be passed
  back to lua_resume.

-- Roberto