From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Amirouche Boubekki Newsgroups: gmane.lisp.guile.devel,gmane.lisp.guile.user Subject: Re: [ann] fibers 0.1.0 Date: Wed, 06 Jul 2016 19:29:38 +0200 Message-ID: <88b0f01471f8aa385f6a4442c260d28e@hypermove.net> References: <87h9c57qf6.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1467826206 28163 80.91.229.3 (6 Jul 2016 17:30:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Jul 2016 17:30:06 +0000 (UTC) Cc: guile-user@gnu.org, guile-devel , guile-devel@gnu.org To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jul 06 19:29:58 2016 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bKqe5-0006h6-HI for guile-devel@m.gmane.org; Wed, 06 Jul 2016 19:29:57 +0200 Original-Received: from localhost ([::1]:35013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKqe4-00004v-Rt for guile-devel@m.gmane.org; Wed, 06 Jul 2016 13:29:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKqdy-0008V7-Ds for guile-devel@gnu.org; Wed, 06 Jul 2016 13:29:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKqdw-0008OA-EU for guile-devel@gnu.org; Wed, 06 Jul 2016 13:29:49 -0400 Original-Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:45869) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKqdr-0008NJ-1r; Wed, 06 Jul 2016 13:29:43 -0400 Original-Received: from mfilter36-d.gandi.net (mfilter36-d.gandi.net [217.70.178.167]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id 8CD63A80D1; Wed, 6 Jul 2016 19:29:40 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter36-d.gandi.net Original-Received: from relay3-d.mail.gandi.net ([IPv6:::ffff:217.70.183.195]) by mfilter36-d.gandi.net (mfilter36-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id QOVD9fXo6gBM; Wed, 6 Jul 2016 19:29:39 +0200 (CEST) X-Originating-IP: 10.58.1.144 Original-Received: from webmail.gandi.net (webmail4-d.mgt.gandi.net [10.58.1.144]) (Authenticated sender: amirouche@hypermove.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPA id DC55BA80D3; Wed, 6 Jul 2016 19:29:38 +0200 (CEST) In-Reply-To: <87h9c57qf6.fsf@pobox.com> X-Sender: amirouche@hypermove.net User-Agent: Roundcube Webmail/1.1.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4b98:c:538::195 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:18468 gmane.lisp.guile.user:12727 Archived-At: (Resent the mail to the mailing list) On 2016-07-04 10:34, Andy Wingo wrote: > Hi all, > > I just released Fibers 0.1.0. Fibers is an experimental facility for > Erlang-like concurrency in Guile 2.2. > > As an example, here is a ping server written in Fibers: > > (define (socket-loop socket store) > (let loop () > (match (accept socket) > ((client . addr) > (set-nonblocking! client) > ;; Disable Nagle's algorithm. We buffer ourselves. > (setsockopt client IPPROTO_TCP TCP_NODELAY 0) > (spawn (lambda () (client-loop client addr store))) > (loop))))) > > As you can see it's straightforward in style. For each client that > comes in, we spawn a fiber to handle the client. Here's the fiber that > handles the client: > > (define (client-loop port addr store) > (let loop () > (let ((line (read-line port))) > (cond > ((eof-object? line) > (close-port port)) > (else > (put-string port line) > (put-char port #\newline) > (force-output port) > (loop)))))) > It's ok to use several put-* procedure instead of one? For example: ``` (put-string port "abc") ``` is not better than: ``` (put-char port #\a) (put-char port #\b) (put-char port #\c) ``` Otherwise said is there still buffering when using non blocking sockets? Does (web client) http-get work vanilla with fiber? Thanks for the hard work!