![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/include/boost/fiber/future/ |
Upload File : |
// Copyright Oliver Kowalke 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_FIBERS_ASYNC_HPP #define BOOST_FIBERS_ASYNC_HPP #include <algorithm> #include <memory> #include <type_traits> #include <utility> #include <boost/config.hpp> #include <boost/fiber/future/future.hpp> #include <boost/fiber/future/packaged_task.hpp> #include <boost/fiber/policy.hpp> namespace boost { namespace fibers { template< typename Fn, typename ... Args > future< typename std::result_of< typename std::enable_if< ! detail::is_launch_policy< typename std::decay< Fn >::type >::value, typename std::decay< Fn >::type >::type( typename std::decay< Args >::type ... ) >::type > async( Fn && fn, Args ... args) { typedef typename std::result_of< typename std::decay< Fn >::type( typename std::decay< Args >::type ... ) >::type result_type; packaged_task< result_type( typename std::decay< Args >::type ... ) > pt{ std::forward< Fn >( fn) }; future< result_type > f{ pt.get_future() }; fiber{ std::move( pt), std::forward< Args >( args) ... }.detach(); return f; } template< typename Policy, typename Fn, typename ... Args > future< typename std::result_of< typename std::enable_if< detail::is_launch_policy< Policy >::value, typename std::decay< Fn >::type >::type( typename std::decay< Args >::type ...) >::type > async( Policy policy, Fn && fn, Args ... args) { typedef typename std::result_of< typename std::decay< Fn >::type( typename std::decay< Args >::type ... ) >::type result_type; packaged_task< result_type( typename std::decay< Args >::type ... ) > pt{ std::forward< Fn >( fn) }; future< result_type > f{ pt.get_future() }; fiber{ policy, std::move( pt), std::forward< Args >( args) ... }.detach(); return f; } template< typename Policy, typename StackAllocator, typename Fn, typename ... Args > future< typename std::result_of< typename std::enable_if< detail::is_launch_policy< Policy >::value, typename std::decay< Fn >::type >::type( typename std::decay< Args >::type ... ) >::type > async( Policy policy, std::allocator_arg_t, StackAllocator salloc, Fn && fn, Args ... args) { typedef typename std::result_of< typename std::decay< Fn >::type( typename std::decay< Args >::type ... ) >::type result_type; packaged_task< result_type( typename std::decay< Args >::type ... ) > pt{ std::forward< Fn >( fn) }; future< result_type > f{ pt.get_future() }; fiber{ policy, std::allocator_arg, salloc, std::move( pt), std::forward< Args >( args) ... }.detach(); return f; } template< typename Policy, typename StackAllocator, typename Allocator, typename Fn, typename ... Args > future< typename std::result_of< typename std::enable_if< detail::is_launch_policy< Policy >::value, typename std::decay< Fn >::type >::type( typename std::decay< Args >::type ... ) >::type > async( Policy policy, std::allocator_arg_t, StackAllocator salloc, Allocator alloc, Fn && fn, Args ... args) { typedef typename std::result_of< typename std::decay< Fn >::type( typename std::decay< Args >::type ... ) >::type result_type; packaged_task< result_type( typename std::decay< Args >::type ... ) > pt{ std::allocator_arg, alloc, std::forward< Fn >( fn) }; future< result_type > f{ pt.get_future() }; fiber{ policy, std::allocator_arg, salloc, std::move( pt), std::forward< Args >( args) ... }.detach(); return f; } }} #endif // BOOST_FIBERS_ASYNC_HPP