A forum for Spin users
You are not logged in.
I would like to have some logic like:
IF the channel chan1 is not empty:
Let X = chan1.pop()
do some stuff with X
But the only way I know how to do this is to explicitly enumerate all possible values of X, ie, if X were of some mtype { BANANA, HOTDOG, MANGO, KOALA }, I would do
mtype tmp;
if
:: chan1 ? BANANA -> tmp = BANANA;
:: chan1 ? HOTDOG -> tmp = HOTDOG;
:: chan1 ? MANGO -> tmp = MANGO;
:: chan1 ? KOALA -> tmp = KOALA;
fi
do some stuff with tmp
Is this the best way to do it? Or is there some method like the ".pop()" I want that I can use?
Thank you!
Last edited by Maxvonhippel (2019-09-17 04:01:15)
Offline
I was a fool, the answer is obvious - I need to use receive, with < >; ie
byte msg;
myChan ? < msg >;
http://spinroot.com/spin/Man/receive.html
Last edited by Maxvonhippel (2019-09-21 23:23:22)
Offline