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

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5351: interrupt a future get boost::unknown_exception
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-18 02:09:11


#5351: interrupt a future get boost::unknown_exception
--------------------------------------------+-------------------------------
  Reporter: qiaozhiqiang@… | Owner: viboes
      Type: Patches | Status: assigned
 Milestone: Boost 1.49.0 | Component: thread
   Version: Boost 1.46.0 | Severity: Problem
Resolution: | Keywords: thread interrupt future unknown_exception
--------------------------------------------+-------------------------------

Comment (by anonymous):

 catch (boost::thread_interrupted& exc)

 if the caller of fi.get() is a boost::thread and is interrupted, get()
 will throw thread_interrupted.
 but the future is interrupted now, not the caller.
 so I recommend get() throw a new class boost::future_interrupted use
 BOOST_THROW_EXCEPTION.


 {{{
 15
 16 int main(int argc, char** argv)
 17 {
 18 boost::packaged_task<int> pt(&foo);
 19 boost::unique_future<int> fi = pt.get_future();
 20 boost::thread task(boost::move(pt)); // launch task on a thread
 21
 22 task.interrupt();
 23
 24 try
 25 {
 26 int v = fi.get();
 27 }
 28 catch (boost::thread_interrupted& exc)
 29 {
 30 std::cout << "OK: " << std::endl;
 31 return 0;
 32 }
 33 catch (boost::exception& exc)
 34 {
 35 std::cout << __LINE__ << " ERROR: " <<
 boost::diagnostic_information(exc) << std::endl;
 36 return 1;
 37 }
 38 catch (...)
 39 {
 40 std::cout << __LINE__ << " ERROR: " << std::endl;
 41 return 2;
 42 }
 43 std::cout << __LINE__ << " ERROR: " << std::endl;
 44 return 3;
 45 }
 }}}

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