Class: Rubylet::Environment

Inherits:
Hash
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/rubylet/environment.rb

Instance Method Summary collapse

Constructor Details

#initialize(req, servlet) ⇒ Environment

Returns a new instance of Environment.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rubylet/environment.rb', line 10

def initialize(req, servlet)
  super()  # required to initialize MonitorMixin
  
  if req.respond_to?(:isAsyncSupported) && req.isAsyncSupported
    @async_callback_condition = new_cond
    @async_callback = nil
    self['async.callback'] = method(:forward_to_async_callback)
  end

  load_headers(req)
  load(req, servlet)
end

Instance Method Details

#on_async_callback(&block) ⇒ Object

Register an async callback. This block will be called when a Rack application calls the ‘async.callback’ proc.

Calls to ‘async.callback’ will block until another thread registers a handler by calling this method.



53
54
55
56
57
58
# File 'lib/rubylet/environment.rb', line 53

def on_async_callback(&block)
  synchronize do
    @async_callback = block
    @async_callback_condition.broadcast
  end
end