これはstd::this_thread::sleep_forとstd::asyncを使用して達成できると読みましたが、うまくいきません。
呼び出される関数は次のとおりです。
bool Log::refresh_data()
{
std::this_thread::sleep_for( std::chrono::minutes( 1 ) );
std::vector<std::string> file_info = this->file.read_pending_if();
for( auto line : file_info )
{
this->append( line );
}
return true;
}
これは別の関数から呼び出されます。以下のコードには、失敗した使用例が 2 つあります。
void MVC::refresh_data()
{
// Error C3867 'Log::refresh_data': non-standard syntax; use '&' to create a pointer to member
std::future<bool> retCode = std::async( this->model_log.refresh_data, 0 );
std::future<bool> retCode = std::async( this->model_log.refresh_data(), 0 );
}
もともと、bool Log::refresh_data()はvoid Log::refresh_data()でしたが、std::asyncは void 戻りが気に入らなかったようです...