[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
Re: GOOPS and fibers - need help understanding what's wrong, bug in fibers/guile?
Wed, 22 Jul 2020 13:28:14 +0100
On Wed, 22 Jul 2020 12:54:20 +0100
Chris Vine <email@example.com> wrote:
> On Wed, 22 Jul 2020 01:56:53 +0200
> Jan Wielkiewicz <firstname.lastname@example.org> 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
(let ((channel (make-channel)))
(sleep 1) ;; do some work
(put-message channel "hello world")))
(simple-format #t "~a~%" (get-message channel))
The point about:
(lambda () (spawn-fiber
(set! v "Set")
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).