Message Passing Functions

The Asynchronous Agents Library provides several functions that let you pass messages among components.

These message-passing functions are used with the various message-block types. For more information about the message-block types that are defined by the Concurrency Runtime, see Asynchronous Message Blocks.


This topic describes the following message-passing functions:

send and asend

The concurrency::send function sends a message to the specified target synchronously and the concurrency::asend function sends a message to the specified target asynchronously. Both the send and asend functions wait until the target indicates that it will eventually accept or decline the message.

The send function waits until the target accepts or declines the message before it returns. The send function returns true if the message was delivered and false otherwise. Because the send function works synchronously, the send function waits for the target to receive the message before it returns.

Conversely, the asend function does not wait for the target to accept or decline the message before it returns. Instead, the asend function returns true if the target accepts the message and will eventually take it. Otherwise, asend returns false to indicate that the target either declined the message or postponed the decision about whether to take the message.


receive and try_receive

The concurrency::receive and concurrency::try_receive functions read data from a given source. The receive function waits for data to become available, whereas the try_receive function returns immediately.

Use the receive function when you must have the data to continue. Use the try_receive function if you must not block the current context or you do not have to have the data to continue.



For examples that use the send and asend, and receive functions, see the following topics:


See also

Asynchronous Agents Library
Asynchronous Message Blocks
send Function
asend Function
receive Function
try_receive Function