Мой вопрос заключается в том, как следует обрабатывать передачу локального std :: vector , когда потоки C ++ требует std :: ref () для использования в Vestors? /> Я скопирую кучу данных из прямой трансляции, когда условия выполняются. Затем этот кусок обрабатывается, пока поток постоянно контролируется. Обработка мучительно медленная, поэтому более одного события обработки может происходить за раз в зависимости от того, как часто/долго пользователь нажимает/удерживает кнопку для.
ex:
Код: Выделить всё
uint32_t start;
uint32_t end;
while(isLive){
//Stream management & evaluation...
//start, end populated as required.
//A chunk of data is isolated from the main stream for processing
std::vector isolatedChunk;
isolatedChunk.resize(end - start);
memcpy(&isolatedChunk[0], &streamBuffer[start], (end - start) * sizeof(float))
//Start a thread to process the isolated chunk. (Takes 500-15,000ms depending on the data)
std::thread myThread(&MyClass::ProcessDataFunction, this, dataCopy);
//Fire & forget. The thread will handle any reporting/result.
myThread.detach();
//Main thread goes on...
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... value-copy
Мобильная версия