From: Chris Vine <vine35792468@gmail.com>
To: guile-user@gnu.org
Subject: Re: GOOPS and fibers - need help understanding what's wrong, bug in fibers/guile?
Date: Wed, 22 Jul 2020 13:28:14 +0100 [thread overview]
Message-ID: <20200722132814.ddafae7536dc479408a6513a@gmail.com> (raw)
In-Reply-To: <20200722125420.df6acee9612d35be10145c3c@gmail.com>
On Wed, 22 Jul 2020 12:54:20 +0100
Chris Vine <vine35792468@gmail.com> wrote:
> On Wed, 22 Jul 2020 01:56:53 +0200
> Jan Wielkiewicz <tona_kosmicznego_smiecia@interia.pl> wrote:
> > Hello,
> >
> > I started writing my project in Guile with GOOPS and fibers (I'll
> > release it once it stops being a shame and starts working!), but I
> > encountered a problem:
> >
> > The example from fibers' manual doesn't work:
> >
> > (lambda ()
> > (spawn-fiber (lambda () (display "hey!\n")))))
> >
> > It doesn't print "hey" as documented in the manual.
> > I use guile 3.0.4 and fibers 1.0.0 (from Guix).
>
> (You are missing '(run-fibers' at the beginnng. Presumably this was
> just a pasting error on your part.)
>
> With that omission corrected, it used to work with guile-2.2. Something
> seems to have changed with guile-3.0, because it only works for me with
> guile-3.0 if you set #:drain? to #t in the call to run-fibers. Without
> that, run-fibers appears to return before init-thunk returns.
>
> So it seems that there is either a bug in the manual or in the fibers
> implementation, probably the latter.
On further reflection I am not sure if it did used to work with
guile-2.2. I think it may be a bug in the manual after all. This works
OK:
(display (run-fibers
(lambda ()
(let ((channel (make-channel)))
(spawn-fiber
(lambda ()
(sleep 1) ;; do some work
(put-message channel "hello world")))
(simple-format #t "~a~%" (get-message channel))
"finished\n"))))
The point about:
(run-fibers
(lambda () (spawn-fiber
(lambda ()
(set! v "Set")
(display "hey!\n")))))
is that spawn-fiber, and so init-thunk, will return straigntaway with a
new fiber object.
So I suspect setting #:drain? to #t will resolve your problem.
It might be worth reporting the bug in the manual as an issue on the
github repository (assuming the above is correct).
next prev parent reply other threads:[~2020-07-22 12:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 23:56 GOOPS and fibers - need help understanding what's wrong, bug in fibers/guile? Jan Wielkiewicz
2020-07-22 11:54 ` Chris Vine
2020-07-22 12:28 ` Chris Vine [this message]
2020-07-24 16:19 ` Jan Wielkiewicz
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=20200722132814.ddafae7536dc479408a6513a@gmail.com \
--to=vine35792468@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).