I got an XC beginners problem:
I have a thread which is quite actively pumping out values through ports the whole time. The values are stored in an array. So it just pumps out the array over and over again (very simplified view).
On the other hand I must be able to write to that array. It would be best if it is done at specified events (e.g. after the array has been pumped out completely), but for starters it does not matter.
Now I got trouble figuring out to read the channel end to get new data and still pump out the array.
If I simply read the pumping stops until I got some data - not what I want
If I use streams the pumping block if nobody updates the data - also not what I want.
I have some events I am waiting for. The I can also try to wait for the time to pas or new data. If new data arrvies I do not wait for the time to pass any longer. But waiting after either waiting or reading should work. like
Code: Select all
this:
switch {
case channel :> c;
case t when timerafter(wait_time) :> void;
}
//ensure that the timer has passed
t when timerafter(wait_time) :>void
But that looks a bit cumbersome to me
Is there an easier way?
Thanks
Marcus