From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Aleix_Conchillo_Flaqu=C3=A9?= Newsgroups: gmane.lisp.guile.user Subject: Re: guile fibers - looking for adivce Date: Mon, 7 Sep 2020 17:25:38 -0700 Message-ID: References: <20200906024757.58dd34cd@interia.pl> <20200907185627.72eca419@interia.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9827"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user To: Jan Wielkiewicz Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Sep 08 02:26:13 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 1kFRSf-0002Rn-IC for guile-user@m.gmane-mx.org; Tue, 08 Sep 2020 02:26:13 +0200 Original-Received: from localhost ([::1]:42902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kFRSe-0005wk-KR for guile-user@m.gmane-mx.org; Mon, 07 Sep 2020 20:26:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kFRSM-0005w3-K2 for guile-user@gnu.org; Mon, 07 Sep 2020 20:25:58 -0400 Original-Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]:44885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kFRSK-000542-65 for guile-user@gnu.org; Mon, 07 Sep 2020 20:25:54 -0400 Original-Received: by mail-lf1-x130.google.com with SMTP id d15so7326236lfq.11 for ; Mon, 07 Sep 2020 17:25:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7hpHfElx13dlCuj/TmuY3mhoyiYVOAcIrZv5sXqFgvk=; b=fa1BNvF5J/hxt8kVm+XOcFKWN7Uf0ZrnDs9tWKdTOqwJvU1XBHGWskM6zj+cMhCSfr /ey9bdjomzGPU/2MbgzmTkFVoep0//AIqZKhJUnEi7o91P6FcSFJuF2eLLKFRl3aIeLv L776Z55etkmWmdCmOjA07rYbNnQf12ux2Pxj92S1dTkubH0fU2nLKhbHmjc9LueuqvyU /t2IDE0UrNBF6IKIbFg4H8GSpQTwgznvgzb4aGqbfaNeN5A2UMK0JbJeqt0LSr5kjsN7 qDczMyhzmErtOr5/P6RPDnNn4PhHCShmUSEDqbe9wUN8H+BNC+Z+a9CLpKRV4AqIo6GU KFdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7hpHfElx13dlCuj/TmuY3mhoyiYVOAcIrZv5sXqFgvk=; b=l4W85+DSBpfzKxHDZYTcpvKQRZkK/2ppK0rPUMnBWcfhIlho2ZZwUijr6NaIJNrdca Cz9Ha+mfOPDLtFSsckdhpfqEbM8O/ec2Gyb4RqfpL6fFOZpNKpNrLZffqinB/+xACXI+ EIm/heqpjwm8sMHKcy+oaeTZZYYo9bN8YvO9Guon1YRzDhpoYL5Q8i27N4eD6iY6dJ0R NmWpS3Gjx/QJjTUZ4z8COgFxtZZYJJfz8NWUTBlYgt+rKaJr/959el30V2KOsvCiIppX tGGsLPw5WEzWEZhiwrxLsCq8XJVSDWPeBh6CB+m+vuC0dKx+XsBBu4ezkzXTEjfABT3G RKQw== X-Gm-Message-State: AOAM5301B2fVA/Zr4kR1UKCSu/mJsMQccGbWgKpeSJ+fde2AFNgM8spR hTCMB2Fv4hhcpgAeHwCCPpXUECLUterpsNmPh/4= X-Google-Smtp-Source: ABdhPJw87/ndIjaWhr7YhV0ouB1OZ1s9NXMoXkikKpLpNXyrah2GnaXtdki8I7DBsI10uPU5e+vj563xvFyvjd7Hp84= X-Received: by 2002:ac2:5586:: with SMTP id v6mr10953472lfg.71.1599524749260; Mon, 07 Sep 2020 17:25:49 -0700 (PDT) In-Reply-To: <20200907185627.72eca419@interia.pl> Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=aconchillo@gmail.com; helo=mail-lf1-x130.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_FROM=0.001, HTML_MESSAGE=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-Content-Filtered-By: Mailman/MimeDel 2.1.23 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:16883 Archived-At: Hi Jan, On Mon, Sep 7, 2020 at 7:56 AM Jan Wielkiewicz < tona_kosmicznego_smiecia@interia.pl> wrote: > Hi! > > Dnia 2020-09-05, o godz. 18:19:49 > Aleix Conchillo Flaqu=C3=A9 napisa=C5=82(a): > > > Hi! > > > > On Sat, Sep 5, 2020 at 3:48 PM Jan Wielkiewicz < > > tona_kosmicznego_smiecia@interia.pl> wrote: > > > > I believe sharing the same object by the two fibers defeats the > > purpose of message passing, because with the way you are doing it you > > find exactly the problem you are having and the only way to fix this > > is by using mutexes. That is, you are trying to use fibers as you > > would use regular threads sharing a resource. Instead, there should > > probably be a main fiber (that holds the object) and send messages > > (with the data needed from the object) to 2 other fibers (those would > > be your methods A and B). > I see, thank you for explanation. This allowed me to understand the > problem doesn't lie in the way I was trying to implement my messaging > through fibers, but rather in the way I was using GOOPS - my custom > method for initializing slots called next-method after doing everything > what caused some weird problems with allocation. > > Are threads and mutexes worth using, if there are fibers already? > I know I'll have to learn this eventually, to fully master programming, > but I'm not sure if there's a great advantage over fibers. > > I don't think mixing threads and fibers is a good idea, so I would stick with fibers. However, you might still want to use mutexes for certain things. This might be useful: https://github.com/golang/go/wiki/MutexOrChannel As they say, sometimes you start over-using channels because it's fun, but a mutex might just be simpler. So if you find yourself getting with too many channels think if a mutex would be easier, and the other way around, if using the mutex is getting too hairy try to think if a channel would be easier. I would suggest reading about Go routines and channels, since it's the same as fibers and there's a lot of information out there. > > > > I haven't used fibers extensively, but I've used Go quite a bit which > > follows the same pattern of channels and message passing and this is > > how you would do it. > > > > Also, the fibers manual also suggests this approach: > > https://github.com/wingo/fibers/wiki/Manual#33-mutation > Yeah, I've read the manual like three times already, but Andy is > somethimes writing sentences from outer space, including the GOOPS > manual. This isn't the level of English I'm currently on. > I guess I'll write some self-explaining examples of GOOPS after I fully > understand it. > > To be honest, I've never used GOOPS so things might be a bit more complicated there, I don't know. But it sounds like you have two options: - Create a fiber with the object and pass data from the object using channels to other fibers. Then return data to the main fiber (or the fiber that has the object) through a channel and update your object. - Make the object global and have fibers that update the object. In this case you would need to use mutexes. Or maybe you find another way? > That said, I might be wrong though. > > > > Hope this helps, > > > > Aleix > > Thanks for explanation, this made my thinking much cleaner. I can get > back to experimenting now! > > Cool, let us know! Aleix