Subject: Re: [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-30 07:25:25
#11499: exception lock_error while intensive locking/unlocking of shared_mutex on
many threads
-------------------------------------+----------------------
Reporter: andrew maclean <agm@â¦> | Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.59.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------------+----------------------
Comment (by andrew maclean <agm@â¦>):
Replying to [ticket:11499 andrew maclean <agm@â¦>]:
>
> {{{
> #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;
>
>
> void threadfunc()
> {
> while (running)
> {
> ReaderLockT lock(gMutex); // exception - eventually... (ymmv)
> std::this_thread::yield();
> }
> }
>
> int main()
> {
> using namespace std;
>
> vector<thread> threads;
> for (int i = 0; i < 256; ++i)
> {
> threads.emplace_back(thread(threadfunc));
> }
>
> 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#comment:4> 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