2 // Copyright Oliver Kowalke 2016.
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_PULL_CONTROL_BLOCK_HPP
8 #define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP
11 #include <type_traits>
13 #include <boost/config.hpp>
14 #include <boost/context/continuation.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 pull_coroutine< T >::control_block {
28 boost::context::continuation c;
29 typename push_coroutine< T >::control_block * other;
31 std::exception_ptr except;
33 typename std::aligned_storage< sizeof( T), alignof( T) >::type storage;
35 static void destroy( control_block * cb) noexcept;
37 template< typename StackAllocator, typename Fn >
38 control_block( context::preallocated, StackAllocator &&, Fn &&);
40 control_block( typename push_coroutine< T >::control_block *, boost::context::continuation &) noexcept;
44 control_block( control_block &) = delete;
45 control_block & operator=( control_block &) = delete;
47 void deallocate() noexcept;
56 bool valid() const noexcept;
59 template< typename T >
60 struct pull_coroutine< T & >::control_block {
69 boost::context::continuation c;
70 typename push_coroutine< T & >::control_block * other;
72 std::exception_ptr except;
74 typename std::aligned_storage< sizeof( holder), alignof( holder) >::type storage;
76 static void destroy( control_block * cb) noexcept;
78 template< typename StackAllocator, typename Fn >
79 control_block( context::preallocated, StackAllocator &&, Fn &&);
81 control_block( typename push_coroutine< T & >::control_block *, boost::context::continuation &) noexcept;
83 control_block( control_block &) = delete;
84 control_block & operator=( control_block &) = delete;
86 void deallocate() noexcept;
94 bool valid() const noexcept;
97 struct pull_coroutine< void >::control_block {
98 boost::context::continuation c;
99 push_coroutine< void >::control_block * other;
101 std::exception_ptr except;
103 static void destroy( control_block * cb) noexcept;
105 template< typename StackAllocator, typename Fn >
106 control_block( context::preallocated, StackAllocator &&, Fn &&);
108 control_block( push_coroutine< void >::control_block *, boost::context::continuation &) noexcept;
110 control_block( control_block &) = delete;
111 control_block & operator=( control_block &) = delete;
113 void deallocate() noexcept;
117 bool valid() const noexcept;
122 #ifdef BOOST_HAS_ABI_HEADERS
123 # include BOOST_ABI_SUFFIX
126 #endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP