From c57d3abeb23e577c31074df898a416b5e2264c39 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Tue, 3 May 2016 19:01:40 +0200 Subject: [PATCH] di not call async() wihtin boost.fiber's async) because of name clash in MSVC --- include/boost/fiber/future/async.hpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/include/boost/fiber/future/async.hpp b/include/boost/fiber/future/async.hpp index 2ba36015..8b9f666b 100644 --- a/include/boost/fiber/future/async.hpp +++ b/include/boost/fiber/future/async.hpp @@ -46,8 +46,15 @@ future< >::type > async( Function && fn, Args && ... args) { - return async( launch_policy::post, - std::forward< Function >( fn), std::forward< Args >( args) ...); + typedef typename std::result_of< + typename std::decay< Function >::type( typename std::decay< Args >::type ... ) + >::type result_t; + + packaged_task< result_t( typename std::decay< Args >::type ... ) > pt{ + std::forward< Function >( fn) }; + future< result_t > f{ pt.get_future() }; + fiber{ std::move( pt), std::forward< Args >( args) ... }.detach(); + return f; } template< typename StackAllocator, class Function, class ... Args > @@ -75,9 +82,15 @@ future< >::type > async( std::allocator_arg_t, StackAllocator salloc, Function && fn, Args && ... args) { - return async( launch_policy::post, - std::allocator_arg, salloc, - std::forward< Function >( fn), std::forward< Args >( args) ...); + typedef typename std::result_of< + typename std::decay< Function >::type( typename std::decay< Args >::type ... ) + >::type result_t; + + packaged_task< result_t( typename std::decay< Args >::type ... ) > pt{ + std::allocator_arg, salloc, std::forward< Function >( fn) }; + future< result_t > f{ pt.get_future() }; + fiber{ std::move( pt), std::forward< Args >( args) ... }.detach(); + return f; } }}