1 # -*- encoding: binary -*-
4 # Middleware that will run the app dispatch in a separate thread.
5 # This middleware is automatically loaded by Rainbows! when using
6 # EventMachine and if the app responds to the +deferred?+ method.
7 class Rainbows::EventMachine::TryDefer < Struct.new(:app)
9 ASYNC_CALLBACK = Rainbows::EvCore::ASYNC_CALLBACK
12 # the entire app becomes multithreaded, even the root (non-deferred)
13 # thread since any thread can share processes with others
14 Rainbows::Const::RACK_DEFAULTS['rack.multithread'] = true
20 EM.defer(proc { catch(:async) { app.call(env) } }, env[ASYNC_CALLBACK])
21 # all of the async/deferred stuff breaks Rack::Lint :<