The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Serialization, Continations and Blocks

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Michael Neumann

Posts: 66
Nickname: backflash
Registered: May, 2003

Michael Neumann is fallen in Love with Ruby
Serialization, Continations and Blocks Posted: Oct 31, 2004 1:18 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Michael Neumann.
Original Post: Serialization, Continations and Blocks
Feed Title: Mike's Weblog
Feed URL: http://www.ntecs.de/blog-old/index.rss?cat=ruby&count=7
Feed Description: Blogging about Ruby and other interesting stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Michael Neumann
Latest Posts From Mike's Weblog

Advertisement
Ruby can't store continuations or blocks on disk! That was one reason why I was initially against using continuations (and blocks) in Wee. But now I have found some solutions to the problem.

Blocks

In the rendering-phase, you usually define some actions and input elements. This is currently done this way:

  def inc; @cnt += 1 end
  def dec; @cnt -= 1 end

  def render_content_on(r)
    r.anchor.action(:inc).with('++')
    r.anchor.action(:dec).with('--')
  end

While with blocks, you can write:

  def render_content_on(r)
    r.anchor.action { @cnt += 1 }.with('++')
    r.anchor.action { @cnt -= 1 }.with('--')
  end

When it comes to storing a session on disk, we simply mark those pages for which a block handler was specified, as "needing another render-pass before being able to respond to an action". So, in the rare case of needing to shutdown the computer, we don't loose any information. It's just that the user has to reload the page.

Continuations

We can rebuild block handlers, by executing their definition (render-phase). But that does not apply to continations. If you serialize a session with active continuations, Wee will replace the continations with marker objects, so that we can later detect that there was an active contination going on. If this happens, Wee will notify the user about this situation and will return to the calling component and call it's method fallback_from_cc. If you want, you can still use old-style call behaviour by passing the name of the return method. Then you won't loose any information.

Another idea is to use DragonFly's checkpointing support. This would be a 100% solution for the whole problem.

Read: Serialization, Continations and Blocks

Topic: My own Web Framework Previous Topic   Next Topic Topic: Refactoring Net::SSH: Part 3

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use