unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: guile-user@gnu.org
Subject: Re: repl-server from fibers task
Date: Wed, 21 Dec 2022 07:43:27 -0800	[thread overview]
Message-ID: <61accd27-1eeb-dd9f-5530-a696732ed5c5@gmail.com> (raw)
In-Reply-To: <c989c8c4-ead8-32bb-340c-dc1949ac7cbd@gmail.com>

On 12/19/22 1:30 PM, Matt Wette wrote:
> Hi All,
>
> I'm trying to get fibers to run in "pure asynchronous" style with a 
> repl-server.
> By "pure asynchronous" style I mean #:hz 0 and possibly 
> #:suspendable-ports #f.
> My only guess is that maybe the repl-server has a continuation barrier 
> in the way.
>
> Either the other task runs, and I get no connection to the 
> repl-server, or vice versa.
>
> Anyone here gotten this to work?  If the code worked below the main 
> terminal
> would be counting along while one could telnet in from another source 
> and use the repl.
>
> Any help appreciated.
>
> Matt
I got something to work:

#!/usr/bin/env guile
# -*- scheme -*-
!#

;; connect to monitor via
;;   $ telnet localhost 37146

(use-modules ((fibers) #:renamer (lambda (s) (if (eq? s 'sleep) 'fsleep 
s))))
(use-modules (fibers scheduler))
(use-modules (system repl server))
(use-modules (system repl coop-server))

(define (sf fmt . args) (apply simple-format #t fmt args))

(define (task1)
   (let loop ((cnt 0))
     (fsleep 1)
     (sf "task1: ~S\n" cnt)
     (loop (1+ cnt))))

(define (monitor)
   (let* ((server (spawn-coop-repl-server)))
     (let loop ()
       (poll-coop-repl-server server)
       (yield-current-task)
       (loop))))

(run-fibers
  (lambda ()
    (spawn-fiber task1)
    (spawn-fiber monitor)
    (fsleep 30))
  #:hz 0 #:install-suspendable-ports? #f)

;;; --- last line ---




      reply	other threads:[~2022-12-21 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-19 21:30 repl-server from fibers task Matt Wette
2022-12-21 15:43 ` Matt Wette [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61accd27-1eeb-dd9f-5530-a696732ed5c5@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).