Issue using std::atomic_flag with worker thread

十年热恋 提交于 2019-12-01 09:30:56

Just replace

thread SanityTestThread(&SanityTest::_rx, *this);

with

thread SanityTestThread(&SanityTest::_rx, this);

You probably intended to pass a pointer to the object and not the object itself (which would result in that object being copied and the member function pointer &SanityTest::_rx being invoked on that copy instead of the original object).

The reason for the error message is essentially that std::atomic_flag doesn't have a copy constructor and so the compiler doesn't generate a default one for your SanityTest class either, but again: you don't want to copy your SanityTest object here anyway.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!