タグ

mutexとc++11に関するmoccos_infoのブックマーク (3)

  • Lock-free Programming in C++ with Herb Sutter

    How to Use Multiple GitHub Accounts Git is a popular tool for version control in software development. It is not uncommon to use multiple Git accounts. Correctly configuring and switching Git accounts is challenging. In this article, we show what Git provides for account configuration, its limitations, and the solution to switch accounts automatically based on a project parent directory location.

    Lock-free Programming in C++ with Herb Sutter
    moccos_info
    moccos_info 2014/11/11
    atomic, compare_exchange_weak/strong
  • C++0x の std::unique_lock - std::defer_lock と std::adopt_lock でちょっと高度なロック管理

    http://cpplover.blogspot.com/2011/07/mutex.html C++ のソースコード中に「途中のreturnや例外に気をつけること」などといったコメントはあってはならないため,補足. // 排他的にアクセスするリソース class exclusive_resource { public : std::vector<int> v ; private : std::mutex m ; public : void lock() { m.lock() ; } void try_lock() { m.try_lock() ; } void unlock() { m.unlock() ; } } ; exclusive_resource res1, res2 ; void thread1() {// res1のみを操作 std::lock_guard< exclusi

    C++0x の std::unique_lock - std::defer_lock と std::adopt_lock でちょっと高度なロック管理
    moccos_info
    moccos_info 2012/11/16
    "C++0x の std::unique_lock - std::defer_lock と std::adopt_lock でちょっと高度なロック管理"
  • C++0x時代の Double-Checked Locking - yamasaのネタ帳

    今回は "Double-Checked Locking" (以下DCL)というマルチスレッドプログラム向けのイディオムを例にして、C++0xの(低レイヤ向け)マルチスレッド機能の利用方法を紹介してみます。 DCLとは、「ロック→条件判定」というロジックを「条件判定→ロック→(再度)条件判定」と書き換えるイディオムで、主に遅延初期化などの処理においてロックのオーバーヘッドを減らすために用いられます。DCLはシンプルかつ効果の高いイディオムだったので、一時期もてはやされました。ところが、DCLはコンパイラやCPUによるリオーダーの影響により正しく動作しない場合があることがわかったため(参考1、参考2)、今ではアンチパターンと呼ばれることすらある始末です。 しかし、DCLの問題点は、メモリモデルに関する知識があまり知られていなかったことと、プログラミング言語の仕様でメモリモデルが正しく定義されて

    C++0x時代の Double-Checked Locking - yamasaのネタ帳
  • 1