lua-users home
lua-l archive

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

We aren't using luaproc but we are doing similar things. Our solution was to have a packing format for Lua data that is savvy about the userdata types we are interested in in addition to the Lua data types and to teach our messaging system to transfer this packed data with appropriate packing and unpacking happening on either end.

In our specific case, right now our foreign data is essentially Objective-C objects though any object system that supported reference counting would work equally well and our userdata just contains a pointer. (Well, actually a pointer and some information about the extra size incurred by the object that we hope to use somewhere to keep GC pressure correct.) Packing one of these objects into the transit data structure adds the pointer to the serialized format but also adds the pointer to a list of embedded pointers hanging off the transfer object and increments the reference count. Unpacking de-serializes into a proxy in the destination (incrementing the reference count as it does so). Destroying the transfer object decrements the reference count for the extra pointers hanging off the transfer object. One could get clever and try to have the deserialization consume the reference thereby avoiding some extra reference count manipulation, but that sort of cleverness makes the code more convoluted.