Class: Wee::Session
- Inherits:
-
AbstractSession
- Object
- RequestHandler
- AbstractSession
- Wee::Session
- Defined in:
- lib/wee/session.rb,
lib/wee/continuation/session.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#component_runner ⇒ Object
Returns the value of attribute component_runner.
-
#page_store ⇒ Object
Returns the value of attribute page_store.
Attributes inherited from RequestHandler
#application, #expire_after, #id, #max_lifetime, #max_requests
Instance Method Summary collapse
- #current_callbacks ⇒ Object
-
#initialize(&block) ⇒ Session
constructor
A new instance of Session.
- #start_request_response_loop ⇒ Object
Methods inherited from AbstractSession
current, #current_context, #get_property, #handle_request, #properties, #properties=
Methods inherited from RequestHandler
#alive?, #handle_request, #statistics, #teminate
Constructor Details
#initialize(&block) ⇒ Session
Returns a new instance of Session.
8 9 10 11 |
# File 'lib/wee/session.rb', line 8 def initialize(&block) super() setup(&block) end |
Instance Attribute Details
#component_runner ⇒ Object
Returns the value of attribute component_runner.
5 6 7 |
# File 'lib/wee/session.rb', line 5 def component_runner @component_runner end |
#page_store ⇒ Object
Returns the value of attribute page_store.
6 7 8 |
# File 'lib/wee/session.rb', line 6 def page_store @page_store end |
Instance Method Details
#current_callbacks ⇒ Object
13 14 15 |
# File 'lib/wee/session.rb', line 13 def current_callbacks @page.callbacks end |
#start_request_response_loop ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/wee/continuation/session.rb', line 27 def start_request_response_loop Thread.abort_on_exception = true Thread.new { Thread.current[:wee_session] = self loop { @context = nil # get a request, check whether this session is alive after every 5 # seconds. while @context.nil? begin Timeout.timeout(5) { @context = @in_queue.pop } rescue Timeout::Error break unless alive? end end # abort thread if no longer alive break if not alive? raise "invalid request" if @context.nil? begin awake process_request sleep rescue Exception => exn @context.response = Wee::ErrorResponse.new(exn) end @out_queue.push(@context) } p "session loop terminated" if $DEBUG } end |