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
13 #include <boost/config.hpp>
14 #include <boost/context/execution_context.hpp>
16 #include <boost/coroutine2/detail/state.hpp>
18 #ifdef BOOST_HAS_ABI_HEADERS
19 # include BOOST_ABI_PREFIX
23 namespace coroutines2 {
26 template< typename T >
27 struct push_coroutine< T >::control_block {
28 boost::context::execution_context ctx;
29 typename pull_coroutine< T >::control_block * other;
31 std::exception_ptr except;
33 static void destroy( control_block * cb) noexcept;
35 template< typename StackAllocator, typename Fn >
36 control_block( context::preallocated, StackAllocator, Fn &&);
38 control_block( typename pull_coroutine< T >::control_block *, boost::context::execution_context const&) noexcept;
40 ~control_block() noexcept;
42 control_block( control_block &) = delete;
43 control_block & operator=( control_block &) = delete;
45 void deallocate() noexcept;
47 void resume( T const&);
51 bool valid() const noexcept;
54 template< typename T >
55 struct push_coroutine< T & >::control_block {
56 boost::context::execution_context ctx;
57 typename pull_coroutine< T & >::control_block * other;
59 std::exception_ptr except;
61 static void destroy( control_block * cb) noexcept;
63 template< typename StackAllocator, typename Fn >
64 control_block( context::preallocated, StackAllocator, Fn &&);
66 control_block( typename pull_coroutine< T & >::control_block *, boost::context::execution_context const&) noexcept;
68 ~control_block() noexcept;
70 control_block( control_block &) = delete;
71 control_block & operator=( control_block &) = delete;
73 void deallocate() noexcept;
77 bool valid() const noexcept;
80 struct push_coroutine< void >::control_block {
81 boost::context::execution_context ctx;
82 pull_coroutine< void >::control_block * other;
84 std::exception_ptr except;
86 static void destroy( control_block * cb) noexcept;
88 template< typename StackAllocator, typename Fn >
89 control_block( context::preallocated, StackAllocator, Fn &&);
91 control_block( pull_coroutine< void >::control_block *, boost::context::execution_context const&) noexcept;
93 ~control_block() noexcept;
95 control_block( control_block &) = delete;
96 control_block & operator=( control_block &) = delete;
98 void deallocate() noexcept;
102 bool valid() const noexcept;
107 #ifdef BOOST_HAS_ABI_HEADERS
108 # include BOOST_ABI_SUFFIX
111 #endif // BOOST_COROUTINES2_DETAIL_PUSH_CONTROL_BLOCK_HPP