Don't pollute global _G space.

zmq3.0
Robert G. Jakabosky 15 years ago
parent c3dd0056e1
commit ffeb63cf7d

@ -83,14 +83,14 @@ function poller_mt:stop()
self.is_running = false self.is_running = false
end end
module(...) local M = {}
function new(pre_alloc) function M.new(pre_alloc)
return setmetatable({ return setmetatable({
poller = zmq.ZMQ_Poller(pre_alloc), poller = zmq.ZMQ_Poller(pre_alloc),
callbacks = {}, callbacks = {},
}, poller_mt) }, poller_mt)
end end
setmetatable(_M, {__call = function(tab, ...) return new(...) end}) return setmetatable(M, {__call = function(tab, ...) return M.new(...) end})

@ -85,26 +85,27 @@ local function new_thread(ctx, action, action_arg, ...)
}, thread_mt) }, thread_mt)
end end
module(...) local M = {}
function set_bootstrap_prelude(code) function M.set_bootstrap_prelude(code)
bootstrap_code = bootstrap_pre .. code .. bootstrap_post bootstrap_code = bootstrap_pre .. code .. bootstrap_post
end end
function runfile(ctx, file, ...) function M.runfile(ctx, file, ...)
return new_thread(ctx, 'runfile', file, ...) return new_thread(ctx, 'runfile', file, ...)
end end
function runstring(ctx, code, ...) function M.runstring(ctx, code, ...)
return new_thread(ctx, 'runstring', code, ...) return new_thread(ctx, 'runstring', code, ...)
end end
local parent_ctx = nil local parent_ctx = nil
function set_parent_ctx(ctx) function M.set_parent_ctx(ctx)
parent_ctx = ctx parent_ctx = ctx
end end
function get_parent_ctx(ctx) function M.get_parent_ctx(ctx)
return parent_ctx return parent_ctx
end end
return M

Loading…
Cancel
Save