2 // Copyright Oliver Kowalke 2014.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
8 #define BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP
12 #include <boost/config.hpp>
13 #include <boost/context/execution_context.hpp>
15 #include <boost/coroutine2/detail/state.hpp>
17 #ifdef BOOST_HAS_ABI_HEADERS
18 # include BOOST_ABI_PREFIX
22 namespace coroutines2 {
25 template< typename T >
26 struct push_coroutine< T >::control_block {
27 boost::context::execution_context< T * > ctx;
28 typename pull_coroutine< T >::control_block * other;
30 std::exception_ptr except;
32 static void destroy( control_block * cb) noexcept;
34 template< typename StackAllocator, typename Fn >
35 control_block( context::preallocated, StackAllocator, Fn &&);
37 control_block( typename pull_coroutine< T >::control_block *, boost::context::execution_context< T * > &) noexcept;
39 control_block( control_block &) = delete;
40 control_block & operator=( control_block &) = delete;
42 void deallocate() noexcept;
44 void resume( T const&);
48 bool valid() const noexcept;
51 template< typename T >
52 struct push_coroutine< T & >::control_block {
53 boost::context::execution_context< T * > ctx;
54 typename pull_coroutine< T & >::control_block * other;
56 std::exception_ptr except;
58 static void destroy( control_block * cb) noexcept;
60 template< typename StackAllocator, typename Fn >
61 control_block( context::preallocated, StackAllocator, Fn &&);
63 control_block( typename pull_coroutine< T & >::control_block *, boost::context::execution_context< T * > &) noexcept;
65 control_block( control_block &) = delete;
66 control_block & operator=( control_block &) = delete;
68 void deallocate() noexcept;
72 bool valid() const noexcept;
75 struct push_coroutine< void >::control_block {
76 boost::context::execution_context< void > ctx;
77 pull_coroutine< void >::control_block * other;
79 std::exception_ptr except;
81 static void destroy( control_block * cb) noexcept;
83 template< typename StackAllocator, typename Fn >
84 control_block( context::preallocated, StackAllocator, Fn &&);
86 control_block( pull_coroutine< void >::control_block *, boost::context::execution_context< void > &) noexcept;
88 control_block( control_block &) = delete;
89 control_block & operator=( control_block &) = delete;
91 void deallocate() noexcept;
95 bool valid() const noexcept;
100 #ifdef BOOST_HAS_ABI_HEADERS
101 # include BOOST_ABI_SUFFIX
104 #endif // BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP