Lua serialization and deserialization library written by C.
local xrpack = require "lxrpack"
xrpack.pack
and xrpack.unpack
can pass data between different threads, the pack
method is used to create memory and pack data, and the unpack
method is used to unpack data and free memory.
xrpack.encode
and xrpack.decode
can pack Lua data structures into characters for network transmission.
encode
and decode
may crash between multiple threads, pack
and unpack
will inevitably cause double free
if used between multiple threads.
If you want to use them safely, remember the following rules:
-
Thread-1
usespack
to generatedata1
, thenThread-2
can only be allowed to callunpack(data1)
once to get the actual data. -
encode
anddecode
must appear in pairs; the sender callsencode
to generate, and the receiver callsdecode
to decode.
For more usage, please leave a message to communicate with the author.