Class: EIO::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/eio/middleware.rb

Overview

The call to EIO.wait blocks until callbacks for all completed requests have been invoked. This workflow is comparable to a 100m race with each line representing a libeio request and EIO.wait being the finishing line / completion barrier. Each I/O operation may be scheduled on a different core and will complete in parallel, proportional to the slowest request, with some minor overhead to boot.

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ Middleware

Returns a new instance of Middleware.



11
12
13
14
# File 'lib/eio/middleware.rb', line 11

def initialize(app, opts = {})
   @app = app
   @options = opts
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
# File 'lib/eio/middleware.rb', line 16

def call(env)
  ret = @app.call(env)
  EIO.wait # flush the libeio request queue (blocks until all requests have been processed)
  ret
end