Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I store a lua_State in shared memory?

I'm guessing not (or, if possible will almost certainly not be worth my time).

The way I'm thinking is to construct a mirror object that contain's offset_ptr's that also sits in the class owns the lua_State that the child processes can use to obtain the locations of the relevant pointers to the state, whether or not that's feasible... there's also other objects that lua_ methods would probably access that I'm not sure how I would pass them the correct addresses...

Guessing I would need a special allocator too, not sure if this is supported?

like image 701
Sam Kellett Avatar asked Nov 16 '25 04:11

Sam Kellett


1 Answers

Since Lua is implemented purely in standard C, allocating a lua_State in shared memory is clearly not supported out-of-the-box. You could look at modifying the source to implement that functionality manually, but it probably wouldn't be worth the trouble. Instead you should keep lua_States out of shared memory, and just copy any important data into shared memory if necessary.

like image 155
Ricky Stewart Avatar answered Nov 17 '25 20:11

Ricky Stewart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!