Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: Rainbows! list <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: Re: Long Polling
Date: Mon, 7 Dec 2009 12:02:34 -0800	[thread overview]
Message-ID: <20091207200234.GA26894@dcvr.yhbt.net> (raw)
In-Reply-To: <fc2a0ebf0912070840r5ffec0d2r5eb72419ae810f21-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Alexander <insinium-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Please, could anybody explain how to create simple long polling app
> with rainbows?

Hi Alexander,

I'm not sure if anybody has actually written one for Rainbows!, but I
think they usually include sleeping or using async.callback like
async_sinatra[1].

For the concurrency models that appear synchronous, you can check out
t/sleep.ru in the test cases for sleep examples:

  (case env['rainbows.model']
  when :FiberPool, :FiberSpawn
    Rainbows::Fiber
  when :Revactor
    Actor
  else # :ThreadPool, :ThreadSpawn
    Kernel
  end).sleep(nr)

I may put that logic into a env["async.sleep"] callback in places where
env["async.callback"] is not available so the synchronous-looking
concurrency models can all share the same code.

If you're using EventMachine, NeverBlock (and in future versions: Rev,
RevThreadSpawn, RevThreadPool, EventMachineDefer,
EventMachineThreadSpawn), you can use "async.callback" or just use
async_synatra which uses "async.callback" internally.

[1] http://github.com/raggi/async_sinatra

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


  parent reply	other threads:[~2009-12-07 20:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07 16:40 Long Polling Alexander
     [not found] ` <fc2a0ebf0912070840r5ffec0d2r5eb72419ae810f21-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-12-07 20:02   ` Eric Wong [this message]
     [not found]     ` <20091207200234.GA26894-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2009-12-08 14:26       ` Alexander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091207200234.GA26894@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/rainbows.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).