added SpoolProc class in uwsgidsl.rb

This commit is contained in:
roberto@oneiric64
2011-12-08 08:30:25 +01:00
parent b48597d3c3
commit 28dcfa4131
+18
View File
@@ -14,6 +14,7 @@ end
$postfork_chain = []
$mulefunc_list = []
$spoolfunc_list = []
module UWSGI
module_function
@@ -21,6 +22,11 @@ module UWSGI
$postfork_chain.each {|func| func.call }
end
module_function
def spooler(args)
$spoolfunc_list[args['ud_spool_func'].to_i].call(args)
end
module_function
def mule_msg_hook(message)
service = Marshal.load(message)
@@ -62,6 +68,18 @@ def postfork(&block)
$postfork_chain << block
end
class SpoolProc < Proc
def initialize(&block)
@block = block
@id = (($spoolfunc_list << block).length-1).to_s
end
def call(args)
args['ud_spool_func'] = @id
UWSGI::send_to_spooler(args)
end
end
def rpc(name, &block)
if block.arity <= 0
UWSGI.register_rpc(name, block, 0)