C++ std::vector of independent std::threads

后端 未结 4 1340
-上瘾入骨i
-上瘾入骨i 2021-01-11 10:11

I´m building a real time software where I have a main infinite loops on main() and threads used to read and process data.

One of the issues is keeping a

4条回答
  •  青春惊慌失措
    2021-01-11 11:02

    You need to use something like

    readerThreads.push_back(move(th));
    

    This will make th an rvalue, and cause the move ctor to be called. The copy ctor of thread was disabled by design (see Anthony Williams' C++ Concurrency In Action).

提交回复
热议问题