Class that enables sending and listening for data between client and workers
parallel.pool.DataQueue
enables 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 process
that calls the constructor, 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. Use spmd
, labSend
,
or labReceive
instead.
Unlike all other handle objects, DataQueue
instances
do remain connected when they are sent to workers.
q
=
parallel.pool.DataQueue
The constructor for a DataQueue
takes no
arguments and returns an object that can be used to send or listen
for messages (or data) from different workers. You call the constructor
only in the process where you want to receive the data. In the usual
workflow, the workers should not be calling the constructor, but should
be handed an existing DataQueue
instance instead.
A parallel.pool.DataQueue object has the following methods.
afterEach | Define a function to call when new data is received |
send | Send data from worker to client using a data queue |
Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).
afterEach
| gcp
| labReceive
| labSend
| parallel.pool.PollableDataQueue
| parfor
| poll
| send
| spmd