mardi 2 juillet 2019

Repetitive execution of a threaded packaged_task

I am new to C++11 threading utilities. In order to execute an algorithm built from several boxes, I chose to use a mix of std::packaged_task around my boxes, std::future to synchronize everything and std::thread to ensure multi threading. My schematized algorithm is:

PrepareData0  -->  ProcessData0  -->  InterpretData0  |
                                                       --> InterpretGlobal
PrepareData1  -->  ProcessData1  -->  InterpretData1  |

Since this should be an unstoppable loop to process a video, a webcam output... I try to create my tasks only once and reuse them after having their state reset using the std::packaged_task::reset method. But it seems to fail with std::future_error. The only choice I have at the moment is to rebuild my tasks each time I want to run my algorithm.

It seems a bit overkill to me. Is there any simple way to reuse already initialized std::packaged_task object in threads?

Aucun commentaire:

Enregistrer un commentaire