lua-users home
lua-l archive

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

In my C/C++ code I have an array of object "slots". these slots are initialized with some data.

A "slot manager" awaits a request for a slot and delivers a member of the array to a user.

The user pushes its "instance data" into a "slot" and does some work. At some point the work is done and the "slot" is returned to the "slot manager"

OK... so I am thinking about adding scripting as a feature of a slot. My current idea is that I will have a master LUA state, and each slot will get a lua thread.

My initial thought was that I would create a new LUA thread when the slots are initialized, but this would require somehow resetting the thread's state between slot allocations... so that each slot user gets a "clean" lua state. I don't see anyway of doing this in the lua API.

I guess the alternative is to remove all references to the thread when the slot is freed (so that the GC can free the memory) and then create a new thread when a slot is allocated.

My concern is thrashing the memory allocator. In my application it is very important to pay careful attention to memory allocations and fragmentation AND to runtime speed.

Can anyone point me in a direction?


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around