[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ann] fibers 0.1.0

From: Amirouche Boubekki
Subject: Re: [ann] fibers 0.1.0
Date: Wed, 06 Jul 2016 19:29:38 +0200
User-agent: Roundcube Webmail/1.1.2

(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)))

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)))
           ((eof-object? line)
            (close-port port))
            (put-string port line)
            (put-char port #\newline)
            (force-output port)

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!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]