Thank you for your answer! I think the example with channels, which I sent later goes in the direction your are describing : )
Yes, I am not planning on modifying shared state and doing the whole mutex stuff. Regards, Zelphir On 1/5/20 3:42 AM, John Cowan wrote: > > > On Sat, Jan 4, 2020 at 5:50 PM Zelphir Kaltstahl > <zelphirkaltst...@posteo.de <mailto:zelphirkaltst...@posteo.de>> wrote: > > I have questions regarding the usage of the fibers library. It seems, > that I cannot find any way to get a computation result back from a > fiber. I also cannot find anything about how to get a value back > from a > fiber, except for channels. > > > FIbers are much more like coroutines than subroutines: they don't > return data, they pass it on. You *can* communicate by mutating > shared data, but it's asking for trouble because of synchronization > issues. Stick to communicating using channels, that's what they are > for. Of course if your fiber both sends and receives on channels to > the same fiber, you risk deadlock if you are not careful to stay > exactly in sync and avoid output buffering. Exactly these rules > apply to shell pipelines, probably the most widespread form of > concurrency in programming as well as the simplest and most reliable. > > > > John Cowan http://vrici.lojban.org/~cowan > co...@ccil.org <mailto:co...@ccil.org> > Deshil Holles eamus. Deshil Holles eamus. Deshil Holles eamus. > Send us, bright one, light one, Horhorn, quickening, and wombfruit. (3x) > Hoopsa, boyaboy, hoopsa! Hoopsa, boyaboy, hoopsa! Hoopsa, boyaboy, > hoopsa! > --Joyce, Ulysses, "Oxen of the Sun" >