lua threads the luabind way
Szymon Gatner <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Couple of questions regarding usage of Lua threads with luabind:
- What is the proper way of taking care of thread's lifetime? Lua docs
say that after
lua_newthread() call, thread is pushed on the Lua stack and is a
subject to the garbage
collection. How to make sure that thread is not collected when it is
still used and
how to finally get rid of it?
- Lua docs also say that lua_resume() "returns LUA_YIELD if the
coroutine yields,
0 if the coroutine finishes its execution without errors, or an error
code in case of errors".
Yet, (if I understand correctly) there is no way of knowing if thread
yielded or finished
with luabind::resume_function or luabind::resume because it only
forwards return code
of function being called in the thread and not the return value of lua_resume().
Atm I am using a workaround like this:
luabind::resume<void>(coro_);
if (lua_status(coro_) == LUA_YIELD) { ... }
what is a better / proper way to do this?
- Functions called from the thread do not use pcall error calback registered
earlier in "master state". Is that expected behavior?
Please help.
Regards,
Szymon Gatner
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb