Switch to unique_ptr for thread pointers in TriviaGame

This commit is contained in:
2016-07-12 20:47:18 +01:00
parent 4bcedace38
commit 273f732d8c
4 changed files with 15 additions and 51 deletions

View File

@ -212,7 +212,7 @@ void TriviaGame::question() {
ah->send_message(channel_id, ":question: **(" + std::to_string(questions_asked) + "/" + std::to_string(total_questions) + ")** " + current_question);
question_start = boost::posix_time::microsec_clock::universal_time();
current_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&TriviaGame::give_hint, this, 0, "")));
current_thread = std::make_unique<boost::thread>(boost::bind(&TriviaGame::give_hint, this, 0, ""));
}
void TriviaGame::give_hint(int hints_given, std::string hint) {
@ -277,9 +277,9 @@ void TriviaGame::give_hint(int hints_given, std::string hint) {
}
if (hints_given < 4) {
current_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&TriviaGame::give_hint, this, hints_given, hint)));
current_thread = std::make_unique<boost::thread>(boost::bind(&TriviaGame::give_hint, this, hints_given, hint));
} else {
current_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&TriviaGame::question_failed, this)));
current_thread = std::make_unique<boost::thread>(boost::bind(&TriviaGame::question_failed, this));
}
}

View File

@ -51,7 +51,7 @@ private:
// <user_id, average_time>
std::map<std::string, int> average_times;
boost::shared_ptr<boost::thread> current_thread;
std::unique_ptr<boost::thread> current_thread;
boost::posix_time::ptime question_start;
};