On Sun, 6 Sep 2020 02:47:57 +0200 Jan Wielkiewicz <tona_kosmicznego_smie...@interia.pl> wrote: > Hello, > > I'm still on my way of integrating Guile Fibers and GOOPS, but I > encountered some weird behavior. > Say I have an object with with one slot being a vector and two methods > accessing the vector concurrently/parallelly. The methods > accessing/editing the vector are time consuming and are meant to be ran > frequently. Assuming I would like to run the methods on separate > fibers, how do I make sure the state of the object doesn't > suddenly change during execution of a method? I would like the methods > to be able to edit the state of the object, but in a cooperative manner. > > The weird behavior I've encountered is that sometimes when running the > first method (A) and right after starting the second method (B), the > method B tries to access the vector before the method A finishes its > job. What should I do to make accessing the vector cooperatively, yet > to run the time consuming on separate fibers for concurrency? > > I was thinking about implementing slots in objects as sending and > receiving messages instead of regular variables, but still there were > some problems with the object state. > > Could someone explain me what should I do?
You should use channels.