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