lua-users home
lua-l archive

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

Hi Mark,

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).

My Lua/APR binding uses the same approach to transfer (a selection of supported) userdata objects between OS threads / Lua states.

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.

Except for this part which has been bothering me ever since I committed the code :-), so thanks for explaining your solution, it seems more robust and definitely "cleaner" so I guess I'll adopt something similar.

 - Peter Odding