From 4d1f12e333bc10d4cb1785336a368baa1c8b4b95 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Sun, 28 Dec 2014 08:07:31 +0100 Subject: [PATCH] extend async() to accept a stack-allocator --- include/boost/fiber/future/async.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/boost/fiber/future/async.hpp b/include/boost/fiber/future/async.hpp index 5ccb24f0..9c489fd6 100644 --- a/include/boost/fiber/future/async.hpp +++ b/include/boost/fiber/future/async.hpp @@ -30,6 +30,17 @@ async( Fn fn) { return std::move( f); } +template< typename StackAllocator, typename Fn > +future< typename std::result_of< Fn() >::type > +async( StackAllocator salloc, Fn fn) { + typedef typename std::result_of< Fn() >::type result_type; + + packaged_task< result_type() > pt( std::forward< Fn >( fn) ); + future< result_type > f( pt.get_future() ); + fiber( salloc, std::move( pt) ).detach(); + return std::move( f); +} + }} #endif // BOOST_FIBERS_ASYNC_HPP