In response to one of the problems with wanting to embed multiple EM applications into a single VM, this will allow one to leave pre-reactor loop callbacks, which will occur after the initial run block.
Input welcome.
Example:
module EventMachine
class <<self
attr_accessor :post_runs
end
@post_runs = []
# Supply either an object responding to #call, or a block.
# If both a block and object are supplied, both will be added.
def self.post_run obj = nil, &blk = nil
@post_runs << obj if obj
@post_runs << blk if blk
end
def self.run
... # usual stuffs
yield
@post_runs.each { |p| p.call }
end
end