User`s guide
11 Functions — Alphabetical List
11-158
labSendReceive
Simultaneously send data to and receive data from another worker
Syntax
dataReceived = labSendReceive(rcvWkrIdx,srcWkrIdx,dataSent)
dataReceived = labSendReceive(rcvWkrIdx,srcWkrIdx,dataSent,tag)
Arguments
dataSent Data on the sending worker that is sent to the receiving
worker; any MATLAB data type.
dataReceived Data accepted on the receiving worker.
rcvWkrIdx labindex of the receiving worker to which data is sent.
srcWkrIdx labindex of the source worker from which data is sent.
tag Nonnegative integer to identify data.
Description
dataReceived = labSendReceive(rcvWkrIdx,srcWkrIdx,dataSent) sends
dataSent to the worker whose labindex is rcvWkrIdx, and receives dataReceived
from the worker whose labindex is srcWkrIdx. The values for arguments rcvWkrIdx
and srcWkrIdx must be scalars. This function is conceptually equivalent to the following
sequence of calls:
labSend(dataSent,rcvWkrIdx);
dataReceived = labReceive(srcWkrIdx);
with the important exception that both the sending and receiving of data happens
concurrently. This can eliminate deadlocks that might otherwise occur if the equivalent
call to labSend would block.
If rcvWkrIdx is an empty array, labSendReceive does not send data, but only receives.
If srcWkrIdx is an empty array, labSendReceive does not receive data, but only sends.