Long Polling

Eric Wong normalperson at yhbt.net
Mon Dec 7 15:02:34 EST 2009

Alexander <insinium at gmail.com> 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

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
  when :Revactor
  else # :ThreadPool, :ThreadSpawn

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

More information about the rainbows-talk mailing list