From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: GOOPS and fibers - need help understanding what's wrong, bug in fibers/guile? Date: Wed, 22 Jul 2020 12:54:20 +0100 Message-ID: <20200722125420.df6acee9612d35be10145c3c@gmail.com> References: <20200722015653.630db7f9@interia.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3152"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Jul 22 13:54:36 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jyDKV-0000fS-An for guile-user@m.gmane-mx.org; Wed, 22 Jul 2020 13:54:35 +0200 Original-Received: from localhost ([::1]:60922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jyDKU-0006Dw-7F for guile-user@m.gmane-mx.org; Wed, 22 Jul 2020 07:54:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jyDKL-0006Dl-At for guile-user@gnu.org; Wed, 22 Jul 2020 07:54:25 -0400 Original-Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:43907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jyDKJ-0004HC-P9 for guile-user@gnu.org; Wed, 22 Jul 2020 07:54:25 -0400 Original-Received: by mail-wr1-x431.google.com with SMTP id a15so1600633wrh.10 for ; Wed, 22 Jul 2020 04:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ooGxI+a0QO/kSZ14rGG0vuHYWB65buENPRMLEpeh8eA=; b=vLCqnTsnIglxY+mRBu8j8A1qGiWid23EQg3Nm3ctEWhDbgmVw9yaFOg1o7WWd17hAP OqQsR1OKw7uJkjHXi0JwMLqcLZZqu9eWTwBSwn5ASwMK3QqVEmKt7/q6/3Kl0DK0n7yH n++kpQEhUx9JqLNuv6BjT0wtVNA0I+t/GuET4ycthwrKRM2IYdQSfpOMfAmg82owhARo KS66uzW5CgqiyLsogf+ABxloxICWf3xnELls4l+71FYgToktC12JiIRxukoHY4QxPNqz QdnVCZ20h/KneNgfvDZCcmfG+Kcyku+yqs7fKN7J/B1E1RCS+l3+QfIBoQGhB5uFnqyn ljzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ooGxI+a0QO/kSZ14rGG0vuHYWB65buENPRMLEpeh8eA=; b=Z+ArpUP/atgzShuk09NCwu6gvvvl0wW4EHiYUi90iA4BHUqcTQ79OmPd6tt1DmAYk3 lBe2lWwS7AFrFxKXY+NQqt+OkVuztl5Jy2KaAevFpeXYmt4YC5vbH2bjN73N9e2gVsBm NqiivzYYnIB2oD8andXnEBgodxlaFC7M2Ci0ThjgcPPMLsTNxWUfaoOid3sX3eGnmZy9 8Nf40fF+bvsz9gF12r4UA9WUTKoxPkkyn+HbQljL2Gb7gLMizuAhs9ESkLgyD3Ton0Sw sF5+HfPYypfMJ3sqFpxFefIkKXfjbLfkN/mqbjsjhX0BanFQ1BAVEBLi5n8HBNykavaJ 3YMw== X-Gm-Message-State: AOAM532uXJy+XH8YlSUvSNfpw+rTjYXpFWYQds8zpJpz/vxlPbYiNwI2 27ULKP+I6X8CKd0ifJKPiIoRxA2/ X-Google-Smtp-Source: ABdhPJwhj9EYJLSiiG9XU6qlfUTDyTbtUsYzd6DNPuElIwB6wFBALjMZ9sc+CiTfYdyXdKZ3twiPFA== X-Received: by 2002:adf:f20a:: with SMTP id p10mr32575278wro.41.1595418861418; Wed, 22 Jul 2020 04:54:21 -0700 (PDT) Original-Received: from bother.homenet ([2002:218:8d5e:10:13ce:f127:73fd:3d50]) by smtp.gmail.com with ESMTPSA id x204sm4191663wmg.2.2020.07.22.04.54.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 04:54:20 -0700 (PDT) Original-Received: from bother.homenet (localhost [127.0.0.1]) by bother.homenet (Postfix) with SMTP id 43DEF269E21 for ; Wed, 22 Jul 2020 12:54:20 +0100 (BST) In-Reply-To: <20200722015653.630db7f9@interia.pl> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=vine35792468@gmail.com; helo=mail-wr1-x431.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16714 Archived-At: On Wed, 22 Jul 2020 01:56:53 +0200 Jan Wielkiewicz 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. > I also tried making a simple proof of concept, but it doesn't seem to > do anything. I would like to understand what's wrong with my code or > report a bug, if this is the case. No errors, warnings, syntax errors, > just silence. > > My code: > > (define-module (blocks block) > #:use-module (fibers) > #:use-module (fibers channels) > #:use-module (oop goops) > #:use-module (srfi srfi-9) ;; records > #:export ( > connect-peers > send-message > handle-message > start-listening)) > > (define-class () > (input #:init-form '() #:getter get-input > #:setter set-input #:init-keyword #:input) > (output #:init-form '() #:getter get-output > #:setter set-output #:init-keyword #:output)) > > ;; Only connection, no messaging started. > (define-method (connect-peers (p1 ) (p2 )) > (let ((p1-p2 (make-channel)) ;; p1 to p2 > (p2-p1 (make-channel))) ;; p2 to p1 > (set-input p1 p2-p1) > (set-output p1 p1-p2) > (set-input p2 p1-p2) > (set-output p2 p2-p1))) > > (define-method (send-message (p ) msg) > (put-message (get-output p) msg)) > > (define-method (handle-message (p )) > (let loop () > (define msg (get-message (get-input p))) > (match (pk msg) > ('ping (send-message p 'pong))) > (loop))) > > (define-method (start-listening (p1 ) (p2 )) > (run-fibers > (lambda () > (spawn-fiber > (lambda () > (connect-peers p1 p2) > (handle-message p1) > (send-message p1 'ping) > (handle-message p2)))))) > > I run this in repl: > > (define p1 (make )) > (define p2 (make )) > > (start-listening p1 p2) TL;DR, and I do not either like or use GOOPS, so I am not sure what you are doing anyway. But try setting #:drain? to #t. Chris