Class that enables sending and polling for data between client and workers
parallel.pool.PollableDataQueue enables sending
and polling for data or messages between workers and client in a parallel
pool while a computation is being carried out. You can get intermediate
values and progress of the computation.
To send data from a parallel pool worker back to the client,
first construct a PollableDataQueue in the client.
Pass this PollableDataQueue into a parfor-loop
or other parallel language construct, such as parfeval.
From the workers, call send to send data back to
the client. At the client, use poll to retrieve
the result of a message or data sent from a worker.
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, PollableDataQueue instances
do remain connected when they are sent to workers.
p =
parallel.pool.PollableDataQueue
The constructor for a PollableDataQueue takes
no arguments and returns an object that can be used to send and poll
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 PollableDataQueue instance
instead.
A parallel.pool.PollableDataQueue object has the following methods.
| poll | Retrieve data sent from a worker |
| send | Send data from worker to client using a data queue |
Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).
parfor-loop, and Poll for the ResultConstruct a PollableDataQueue.
p = parallel.pool.PollableDataQueue;
Start a parfor-loop, and send a
message, such as data with the value 1.
parfor i = 1 send(p, i); end
poll(p)
1
For more details on polling for data using a
PollableDataQueue, see poll.
afterEach | gcp | labReceive | labSend | parallel.pool.DataQueue | parfeval | parfevalOnAll | parfor | poll | send