I'm trying to use a thread on a method of a class I created. The thread supposes to read the content of the file into a queue.
Here are the methods:
void MessageSender::readAdminFile()
{
std::queue<std::string> messageQueue;
std::thread t(getMassage, std::ref(messageQueue));
t.join();
}
void MessageSender::getMassage(std::queue<std::string>& messageQueue)
{
while (true)
{
mtx.lock();
std::ifstream db;
std::string line, massage;
db.open(MSFILE);
if (db.is_open())
{
while (std::getline(db, line))
{
massage.append(line + "\n");
}
std::cout << massage;
messageQueue.push(massage);
}
mtx.unlock();
std::this_thread::sleep_for(std::chrono::seconds(60));
}
}
Errors:
Error (active) E0289 no instance of constructor "std::thread::thread" matches the argument list
Error C3867 'MessageSender::getMassage': non-standard syntax; use '&' to create a pointer to member