[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GOOPS and fibers - need help understanding what's wrong, bug in fibe
From: |
Chris Vine |
Subject: |
Re: GOOPS and fibers - need help understanding what's wrong, bug in fibers/guile? |
Date: |
Wed, 22 Jul 2020 13:28:14 +0100 |
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).