What is the difference between DataQueue and PollableDataQueue

조회 수: 3 (최근 30일)
Jim Hokanson
Jim Hokanson 2018년 1월 6일
댓글: Jim Hokanson 2018년 1월 6일
What is the difference between parallel.pool.DataQueue and parallel.pool.PollableDataQueue. It seems the pollable queue is the same as the data queue but with the ability to directly extract the next queue item, rather than rely on a callback method. Are there other differences (functionally or with performance)? Is my understanding correct?

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 6일
You can only afterEach on a non pollable queue. You can only check the queue size or poll a pollable queue. That said, I do not know why the two could not have been merged.
The documentation also says that:
"Unlike all other handle objects, PollableDataQueue instances do remain connected when they are sent to workers."
The practical implications of that do not come to mind.
Note by the way that the documentation on the two varieties of queue both say that the values are serialized and sent and deserialized, which answers points from your other question.
  댓글 수: 1
Jim Hokanson
Jim Hokanson 2018년 1월 6일
Oops, I skimmed through the docs a bit too quickly! I guess the big issue is that poll() or afterEach() consumes the queue, so if one is engaged it isn't clear how the other would also get the same data. I'll have to change some of my initial (untested) code because I actually was using a queue first in poll mode and then switching to callback mode. A workaround for this should be fairly straightforward now that I'm aware it is an issue.
Regarding the "remain connected" documentation, which is present in both queues, I think that means that the same object is present in both processes (or they act as one). For the pollable queue I think this means you can ask the length in the sender or the receiver. Also, presumably deleting the queue in one process deletes the queue in the other ... (not tested)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Asynchronous Parallel Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by