From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=0.0 required=3.0 tests=MIME_QP_LONG_LINE, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Alexander Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: Long Polling Date: Tue, 8 Dec 2009 17:26:50 +0300 Message-ID: References: <20091207200234.GA26894@dcvr.yhbt.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1260282421 3514 80.91.229.12 (8 Dec 2009 14:27:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 8 Dec 2009 14:27:01 +0000 (UTC) To: "Rainbows! list" Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Tue Dec 08 15:26:54 2009 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ZjMoAVWoiBbu2BDpQ8WsGST1IClcf7hHvkfNLQEZ7uI=; b=Z6TAWMebX7L6hYxhgGEiqc8d/DpQQ/VzXMfRkEuq2wMNXnL3Hs4N5CYIbkjs86bA26 BZaSodrHUPWWEWcto9cz/v1umEMyEeCetlo/IrLZbiBFymSwtHX3g9rhFwknqQQDog3f TKJT5TyEvtsZ9X9F58iODyJIEBc4D31Lke9rA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=b6S2hY93KpXZHtIYDNpidUXCmiRo2SAoUaX9S55FjEtpjtdHixYsOUV306hpeVDjG2 pldwEJd5XOBC1QvI8/pkhVHvUkSU1VCs0v/FRlqZblMpBPm33hdU56d8Ue2Li7VNg2hZ VBeH0WAZkWqoCIxs5RE8Qst+tON0QEf7mDqKk= In-Reply-To: <20091207200234.GA26894-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:37 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1NI11i-0000yN-Ct for gclrrg-rainbows-talk@m.gmane.org; Tue, 08 Dec 2009 15:26:54 +0100 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id EC72E18582C2; Tue, 8 Dec 2009 09:26:53 -0500 (EST) Received: from mail-ew0-f210.google.com (mail-ew0-f210.google.com [209.85.219.210]) by rubyforge.org (Postfix) with ESMTP id 49C1418582C7 for ; Tue, 8 Dec 2009 09:26:51 -0500 (EST) Received: by ewy2 with SMTP id 2so4030601ewy.7 for ; Tue, 08 Dec 2009 06:26:50 -0800 (PST) Received: by 10.213.79.82 with SMTP id o18mr956780ebk.87.1260282410225; Tue, 08 Dec 2009 06:26:50 -0800 (PST) Hello Eric! Thank You very much! After some unsuccessful attempt to construct it, I mean, that finaly, a got worked class. So, if intresting, you can look it require 'sinatra/async' class LongPollingServlet < Sinatra::Base register Sinatra::Async enable :show_exceptions def initialize @queue =3D [] end aget '/' do @queue << EM.Callback { |message| body message } end get '/pull/:message' do |message| obj =3D @queue.shift obj.call message if obj end end run LongPollingServlet.new Thanks for explains, YR, Alexander. 2009/12/7 Eric Wong > > Alexander 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: > > =A0(case env['rainbows.model'] > =A0when :FiberPool, :FiberSpawn > =A0 =A0Rainbows::Fiber > =A0when :Revactor > =A0 =A0Actor > =A0else # :ThreadPool, :ThreadSpawn > =A0 =A0Kernel > =A0end).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 _______________________________________________ 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