Re: [Boost-bugs] [Boost C++ Libraries] #3848: Boost.Exception and transporting exceptions between threads

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3848: Boost.Exception and transporting exceptions between threads
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-25 13:57:16


#3848: Boost.Exception and transporting exceptions between threads
--------------------------------------------------+-------------------------
  Reporter: Nikki Chumakov <nikkikom@…> | Owner: emildotchevski
      Type: Bugs | Status: reopened
 Milestone: | Component: exception
   Version: Boost 1.40.0 | Severity: Problem
Resolution: | Keywords: exception thread safety
--------------------------------------------------+-------------------------

Comment(by Nikki Chumakov <nikkikom@…>):

 This simple patch would help:

 {{{
 --- boost.1.40/exception/info.hpp 2009-10-09 23:11:15.000000000 +0400
 +++boost/exception/info.hpp 2010-01-25 14:50:03.000000000 +0300
 @@ -10,6 +10,7 @@
  #include <boost/exception/to_string_stub.hpp>
  #include <boost/exception/detail/error_info_impl.hpp>
  #include <boost/shared_ptr.hpp>
 +#include <boost/thread.hpp>
  #include <map>

  namespace
 @@ -121,19 +122,25 @@
              error_info_map info_;
              mutable std::string diagnostic_info_str_;
              mutable int count_;
 + mutable mutex mux_;

              void
              add_ref() const
                  {
 + unique_lock<mutex> lock (mux_);
                  ++count_;
                  }

              void
              release() const
                  {
 + unique_lock<mutex> lock (mux_);
                  if( !--count_ )
 + {
 + lock.unlock ();
                      delete this;
                  }
 + }
              };
          }
 }}}

 However the atomic count_ implementation would be much more efficient.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3848#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:02 UTC