[Boost-bugs] [Boost C++ Libraries] #5351: [boost::thread] interrupt a future get boost::unknown_exception

Subject: [Boost-bugs] [Boost C++ Libraries] #5351: [boost::thread] interrupt a future get boost::unknown_exception
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-22 01:33:39


#5351: [boost::thread] interrupt a future get boost::unknown_exception
---------------------------------------------------------+------------------
 Reporter: qiaozhiqiang@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.46.0 | Severity: Problem
 Keywords: thread interrupt future unknown_exception |
---------------------------------------------------------+------------------
 {{{
 It may be a bug of the thread or future.

 in
 boost_1_46_0/doc/html/thread/synchronization.html

 it says:
 these Member functions:
 shared_future class template:
 Member function get()
 Member function wait()
 Member function timed_wait()
 and
 unique_future class template:
 Member function get()
 Member function wait()
 Member function timed_wait()

 Throws:
 ........
 boost::thread_interrupted if the result associated with *this is not
  ready at the point of the call, and the [current] thread
 is interrupted.
 ............


 but it throws boost::unknown_exception.
 and the [current] thread is interrupted.
 Should be
 the [working] thread is interrupted ?

> > [Windows XP, VC++ 10, boost 1.46]
> > When interrupt a future, the future.get() throw
 boost::unknown_exception,
> > Not boost::thread_interrupted.
> >
> > Class boost::thread_interrupted should have a base class for
> > current_exception_impl() to catch it ? or use BOOST_THROW_EXCEPTION to
 throw ?
 //////////

 namespace boost
 {

     class thread_interrupted
     {};
 }

 These function use [ throw thread_interrupted(); ] :
 this_thread ::interruption_point() // pthread / win32
 this_thread::interruptible_wait() // win32
 interruption_checker:: check_for_interruption()// pthread
 /////////////


 // [Windows XP, VC++ 10, boost 1.46]
 #include <boost/thread.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 #include <boost/thread/future.hpp>
 using namespace boost::posix_time;
 using namespace boost;

 int foo()
 {
         this_thread::sleep(seconds(1000));
         return 0;
 }


 int main(int argc, char** argv)
 {
         boost::packaged_task<int> pt(&foo);


         boost::unique_future<int> fi = pt.get_future();
         boost::thread task(std::move(pt)); // launch task on a thread

         task.interrupt();

         try
         {
                 int v = fi.get();
         }
         catch (boost::exception& exc)
         {
                 std::cerr << "ERROR: " <<
 boost::diagnostic_information(exc) << std::endl;
         }
 }


> >
> > // unknown_exception//////////////////
> > ERROR: Throw in function (unknown)
> > Dynamic exception type: class
 boost::exception_detail::clone_impl<class
> > boost::unknown_exception>
> > std::exception::what: Unknown exception


 }}}

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