Send and listen for data between client and workers
A DataQueue
enables asynchronous sending data or messages from
workers back to the client in a parallel pool while a computation is carried out. For example,
you can get intermediate values and an indication of the progress of the
computation.
To send data from a parallel pool worker back to the client, first construct a
DataQueue
in the client. Pass this DataQueue
into a
parfor
-loop or other parallel language construct, such as
spmd
. From the workers, call send
to send data back
to the client. At the client, register a function to be called each time data is received by
using afterEach
.
You can call send
from the worker or client that creates the
DataQueue
, if required.
You can construct the queue on the workers and send it back to the client to enable
communication in the reverse direction. However, you cannot send a queue from one worker
to another. To transfer data between workers, use spmd
,
labSend
, or labReceive
instead.
Unlike all other handle objects, DataQueue
and
PollableDataQueue
instances do remain connected when they are sent to
workers.
creates an
object that can be used to send or listen for messages (or data) from different workers.
Create the q
=
parallel.pool.DataQueueDataQueue
on the worker or client where you want to receive
the data.
afterEach
| gcp
| labReceive
| labSend
| parallel.pool.PollableDataQueue
| parfor
| poll
| send
| spmd