Re: lua threads the luabind way

Belhorma Bendebiche <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
You can prevent a thread from being collected the same way as any other
value, just put a reference to it in the registry. When done with it, remove
the reference and let Lua take care of the rest.

On Tue, Oct 12, 2010 at 3:23 PM, Szymon Gatner <[email protected]>wrote:

> 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
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.