[Boost-bugs] [Boost C++ Libraries] #4710: Missing async()

Subject: [Boost-bugs] [Boost C++ Libraries] #4710: Missing async()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-10-05 00:58:37


#4710: Missing async()
------------------------------+---------------------------------------------
 Reporter: dave | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: threads
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------------------------------
 The lack of an `async()` call makes futures awfully cumbersome to use. I
 hacked up this nullary prototype for C++03. It's better than nothing!

 {{{
 #!cpp
 #include <boost/thread.hpp>
 #include <boost/utility/result_of.hpp>

 template <class F>
 boost::detail::thread_move_t<boost::unique_future<typename
 boost::result_of<F()>::type> >
 async(F f)
 {
     typedef typename boost::result_of<F()>::type R;
     boost::packaged_task<R> pt( f );

     typedef boost::unique_future<R> future;
     future ret = pt.get_future();
     boost::thread( boost::move(pt) ).detach();
     return boost::move(ret);
 }
 }}}

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