On Tue, Sep 8, 2020 at 12:48 AM Chris Vine <vine35792...@gmail.com> wrote:
> On Mon, 7 Sep 2020 17:25:38 -0700 > Aleix Conchillo Flaqué <aconchi...@gmail.com> wrote: > [snip] > > 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? > > The OP should use channels. It is a bad idea to mix mutexes (which are > a construct for native OS threads) with fibers, because fibers run as > delimited continuations, a group of which may be running on a > particular thread. To synchronize fibers, you use channels. > > Guile's atomic variables (boxes) are available and can be used with > fibers because they do not block, but to use them you really need to > know what you are doing, just as you do if you are using them in C. > Atomic variables do synchronize memory, but they do not provide mutual > exclusion (they don't block) and so require expert skills: don't use > them if you don't know how to use atomic compare-and-swap correctly. > > This is what the guile fibers manual has to say: > > [snip] > > Ooops, duh... Thank you Chris! I don't know what I was thinking when I wrote that, I guess just about Go. Funny enough, I read that fibers section about mutexes the day before, so it clearly didn't stick. So, Jan, ignore my last email and stick to channels. My apologies for the confusion. Aleix