You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
After showing a simple thread pool with Boost.Asio in the last post i’m going to have a look at doing the same thing with the threading facilities in C++11. The biggest difference is that we don’t have the Asio library so we have to reproduce the relevant functionality ourselves. The declarations remain mostly the same except that the ThreadPool class doesn’t have the io_service members anymore bu
C++11では<future>ヘッダが導入され、 簡単に非同期の処理が実装できるようになった。 以下では用途毎に実装方法をまとめる。 thread間での同期の話はせず、あくまで完全に非同期な処理についてまとめる。 戻り値が必要ない場合(Thread-per-message pattern) とりあえず非同期に実行できればいい場合。 実行時間を短縮するために複数の独立な処理を並列に実行するなどの応用が考えられる。 std::threadを使用する。最も基本的な使い方は以下の通りである: auto th1 = std::thread([]{ do_long_work(); }); do_another_things(); th1.join(); std::threadの引数に実行したい関数を渡す。 関数に引数を与えたい場合は、std::thread(func, arg)のように行う。 プログラ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く