Modify

Opened 7 years ago

Closed 5 years ago

#4710 closed Feature Requests (fixed)

c++11 compliance: : Missing async()

Reported by: Dave Abrahams Owned by: viboes
Milestone: Boost 1.52.0 Component: thread
Version: Boost 1.44.0 Severity: Problem
Keywords: async standard Cc: viboes

Description

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!

#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);
}

Attachments (0)

Change History (9)

comment:1 Changed 7 years ago by viboes

Component: threadsthread
Type: BugsFeature Requests

comment:2 Changed 6 years ago by viboes

Cc: viboes added
Keywords: async standard added

comment:3 Changed 6 years ago by anonymous

Summary: Missing async()c++11 complicance: : Missing async()

comment:4 Changed 6 years ago by viboes

Summary: c++11 complicance: : Missing async()c++11 compliance: : Missing async()

comment:5 Changed 6 years ago by viboes

Owner: changed from Anthony Williams to viboes
Status: newassigned

comment:6 Changed 5 years ago by viboes

Milestone: To Be DeterminedBoost 1.52.0

comment:7 Changed 5 years ago by viboes

Add

template <class F, class... Args>
  future<typename result_of<F(Args...)>::type>
  async(F&& f, Args&&... args);
template <class F, class... Args>
  future<typename result_of<F(Args...)>::type>
  async(launch policy, F&& f, Args&&... args);

to conform with c++11.

comment:8 in reply to:  7 Changed 5 years ago by viboes

Replying to viboes:

Add

template <class F, class... Args>
  future<typename result_of<F(Args...)>::type>
  async(F&& f, Args&&... args);
template <class F, class... Args>
  future<typename result_of<F(Args...)>::type>
  async(launch policy, F&& f, Args&&... args);

to conform with c++11.

I will implement these prototypes later on.

For the time been, the minimal request has benn done.

comment:9 Changed 5 years ago by viboes

Resolution: fixed
Status: assignedclosed

Merged from trunk [80450].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.