Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
533 B
32 lines
533 B
|
|
local actions = {} |
|
|
|
local atexit |
|
|
|
if _VERSION >= 'Lua 5.2' then |
|
|
|
atexit = function (fn) |
|
actions[#actions+1] = setmetatable({}, { __gc = fn }) |
|
end |
|
|
|
else |
|
|
|
local newproxy = newproxy |
|
local debug = debug |
|
local assert = assert |
|
local setmetatable = setmetatable |
|
|
|
local function gc(fn) |
|
local p = assert(newproxy()) |
|
assert(debug.setmetatable(p, { __gc = fn })) |
|
return p |
|
end |
|
|
|
atexit = function (fn) |
|
actions[#actions+1] = gc(fn) |
|
end |
|
|
|
end |
|
|
|
return atexit |
|
|
|
|