Home > Articles > Programming > General Programming/Other Languages

  • Print
  • + Share This
This chapter is from the book

Channel Poll Operations

It is also possible to limit the effect of a receive statement to just the copying of parameter values from message fields, without removing the message from the channel. These operations are called channel poll operations. Any receive statement can be turned into a poll operation by placing angle brackets around its list of parameters. For instance, assuming that we have declared a channel q with two message fields of type int, the receive statement

q?<eval(y),x>

where x and y are variables, is executable only if channel q contains at least one message and if the first field in that message has a value that is equal to the current value of variable y. When the statement is executed the value of the second field in the incoming message is copied into variable x, but the message itself is not removed from the channel.

  • + Share This
  • 🔖 Save To Your Account