In .h
class A{ std::thread thread; std::mutex mutex; std::condition_variable cv; bool run; std::queue< ResourceData > queue; public: bool resource_empty( void ){return !this->queue.empty();} ... In implementation
while( this->run ){ std::unique_lock<std::mutex> lk(this->mutex); cv.wait( lk, /* Сюда нужно вставить указатель на функцию */ this->resource_empty ); // просто this->queue.empty не работает // cv.wait( lk, []{ return !this->queue.empty();} ); и так } It works only if the function is outside the class and without parameters .
I want the thread to wait for data to arrive in the queue. Maybe then there is another way of using class data without std :: condition_variable?