[Boost-bugs] [Boost C++ Libraries] #11499: exception lock_error while intensive locking/unlocking of shared_mutex on many threads

Subject: [Boost-bugs] [Boost C++ Libraries] #11499: exception lock_error while intensive locking/unlocking of shared_mutex on many threads
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-07-25 23:07:06


#11499: exception lock_error while intensive locking/unlocking of shared_mutex on
many threads
------------------------------------+------------------------------
 Reporter: andrew maclean <agm@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.57.0
 Severity: Problem | Keywords:
------------------------------------+------------------------------
 {{{
 #include "stdafx.h"
 #include <boost/thread/shared_mutex.hpp>
 #include <thread>
 #include <mutex>
 #include <shared_mutex>
 #include <atomic>
 #include <vector>

 using MutexT = boost::shared_mutex;
 using ReaderLockT = std::lock_guard<MutexT>;
 using WriterLockT = std::shared_lock<MutexT>;

 MutexT gMutex;
 std::atomic<bool> running = true;

 long reads = 0;

 void read()
 {
    while (running)
    {
       ReaderLockT lock(gMutex);
       std::this_thread::yield();
       ++reads;
    }
 }

 int main()
 {
    using namespace std;

    vector<thread> threads;
    for (int i = 0; i < 256; ++i)
    {
       threads.emplace_back(thread(read));
    }

    string str;

    getline(std::cin, str);
    running = false;

    for (auto& thread : threads)
    {
       thread.join();
    }

    return 0;
 }


 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11499>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC