lua-users home
lua-l archive

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


I'm going to create a lot of threads, and then I will
resume one after another. I want to have a table with
just the threads I create in order to iterate the
elements of it to revive them. If I use the registry
table then i should use a linked list to have easy
access to all the threads, because the registry will
have also another kind of data. That's why I want a
new table :)

Thanks a lot for your reply Sam!, i will try that
later when I get home. :-D

Best regards, 
Vertexar.

ps. sorry about my crappy english. :/




--- Sam Roberts <sroberts@bycast.com> wrote:

> On Tue, Apr 24, 2007 at 02:20:10PM -0700, Leandro
> Pelorosso wrote:
> > Hi. I'm trying to create lots of threds and i'm
> having
> > troubles. I was wondering if someone could help
> me.
> > 
> > If I'm going to create lots of threads I would
> like to
> > keep their references somewhere else other than
> the
> > stack. Where can I store them?. 
> 
> > I know i can do this: luaL_ref(L,
> LUA_REGISTRYINDEX )
> > where L represents the new thread. But doing this
> i'm
> 
> Unless the new thread has itself on its stack
> (unlikely, unless you
> called lua_xmove()), you should be using the "L"
> that was passed to
> lua_newthread().
> 
> > using the registry table and i want to use a new
> table
> > created by me. I'm having troubles creating a new
> > table. I can't get the new table's index to use as
> > luaL_ref parameter. 
> 
>   lua_newtable(L);
>   int table_index = lua_gettop(L);
>   lua_State* thread_L = lua_newthread(L);
>   int thread_ref = luaL_ref(L, table_index);
>   ... store the table at table_index somewhere?
> }
> 
> 
> {
>   ...
>   table_index = where was it stored?
>   thread_ref = "" ?
> 
>   lua_rawgeti(L, table_index, thread_ref)
>   lua_State* thread_L = lua_tothread(L, -1);
> 
>   ...
> 
> 
> But you need to put the new table somewhere where
> you can find it, in
> the registry, as a global, leave it on the stack,
> something, because
> you'll need to supply an index to it before calling
> lua_rawgeti().
> 
> Why not just use the ref mechanism with the
> registry? The registry
> exists pretty much as a convenient scratch table for
> this kind of thing.
> Are you anticipating some kind of problem?
> 
> Sam
> 
> 


------------------------------------
Dark Designs
www.darkdesigns.com.ar
Sign our Guestbook!

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com