parallel.pool.PollableDataQueue
Send and poll data between client and workers
Description
A PollableDataQueue object enables synchronous sending and polling for
data or messages between the client and workers in a parallel pool during a computation. For
example, from a worker, you can send intermediate values to the client or another worker and
use the values in another computation. You can also:
Send data from the client or any worker.
Create a
PollableDataQueueobject that allows only the client or worker that created the queue to receive data.Create a
PollableDataQueueobject that allows the client or any worker in the pool to receive data. (since R2025a)
Unlike all other handle objects, PollableDataQueue and
DataQueue objects remain connected when you transfer them.
Creation
Syntax
Description
creates a q =
parallel.pool.PollableDataQueuePollableDataQueue object
that you can use to send and poll for data between the client and workers. The resulting
PollableDataQueue object can be polled only by the client or worker that
creates it. Create the PollableDataQueue on the worker or client where you want
to receive the data.
sets the destination behavior of the q =
parallel.pool.PollableDataQueue(Destination=destination)PollableDataQueue object. (since R2025a)
If you want the client or any worker to be able to poll the
PollableDataQueue object to receive data, set
Destination="any".
Input Arguments
Properties
Object Functions
Examples
Tips
You can only manually retrieve data or messages sent using a
PollableDataQueueobject. To automatically process data after it is received on the client, use aparallel.pool.DataQueueobject to send the data instead.Before R2025a: To send data from a parallel pool worker back to the client, first create a
PollableDataQueueobject at the client. Pass thisPollableDataQueueobject in aparfor-loop or other parallel language construct, such asparfeval. From the workers, callsendto send data back to the client. At the client, usepollto retrieve the result of a message or data sent from a worker.Before R2025a: To send data from the client to the workers, create the queue on the workers and send it back to the client. For an example of this workflow, see Receive Communication on Workers.
Before R2023b: You cannot send data from one worker to another. To transfer data between workers, use
spmd,spmdSend, orspmdReceiveinstead.