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-1usespackto generatedata1, thenThread-2can only be allowed to callunpack(data1)once to get the actual data. -
encodeanddecodemust appear in pairs; the sender callsencodeto generate, and the receiver callsdecodeto decode.
For more usage, please leave a message to communicate with the author.