parallel.pool.DataQueue
Send and listen for data between client and workers
Description
A DataQueue
object enables asynchronous and automatic processing
of data or messages sent between workers and client in a parallel pool while a computation is
carried out. For example, you can send intermediate values to the client and automatically
calculate the progress of the computation.
To send data from a parallel pool worker back to the client, first create a
DataQueue
object at 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, specify a function to automatically process the data received by
using afterEach
.
You can call
send
from the worker or client that created theDataQueue
if required.DataQueue
sends the data only to the client or worker that created theDataQueue
.You can create the queue on the workers and send it back to the client to enable communication in the reverse direction.
Before R2023b: You cannot send a queue from one worker to another. To transfer data between workers, use
spmd
,spmdSend
, orspmdReceive
instead.Unlike all other handle objects,
DataQueue
andPollableDataQueue
instances do remain connected when they are sent to workers.
Creation
Description
creates an object that you can use to send or listen for
messages (or data) between the client and workers. Create the q
=
parallel.pool.DataQueueDataQueue
on the worker or client where you want to receive the data.
Properties
Object Functions
Examples
Tips
You can only automatically process data or messages sent using a
DataQueue
object. To manually retrieve data after it has been received on the client or a worker, use aparallel.pool.PollableDataQueue
object to send the data instead.
Extended Capabilities
Version History
Introduced in R2017a