メモ

プログラムを書いているときに詰まった部分などを備忘録的に書いていきます。

2015-06-24から1日間の記事一覧

Singletonでのthread終了時にjoinで固まる

VisualStudio環境での話です(VS2012で確認) gcc(4.9.2)環境では正常に動作します。 #include <thread> #include <atomic> #include <chrono> #include <iostream> class Hoge { public: static Hoge& get() { static Hoge hoge; return hoge; }; void run() { while( false == m_end ) { sleep(</iostream></chrono></atomic></thread>…

Windows、linuxで共通のsleep

c++11限定だけど #include <thread> #include <chrono> void sleep(unsigned int ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); }</chrono></thread>