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_PULL_CONTROL_BLOCK_HPP
8 #define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP
12 #include <type_traits>
14 #include <boost/config.hpp>
15 #include <boost/context/execution_context.hpp>
17 #include <boost/coroutine2/detail/state.hpp>
19 #ifdef BOOST_HAS_ABI_HEADERS
20 # include BOOST_ABI_PREFIX
24 namespace coroutines2 {
27 template< typename T >
28 struct pull_coroutine< T >::control_block {
29 boost::context::execution_context ctx;
30 typename push_coroutine< T >::control_block * other;
32 std::exception_ptr except;
34 typename std::aligned_storage< sizeof( T), alignof( T) >::type storage;
36 static void destroy( control_block * cb) noexcept;
38 template< typename StackAllocator, typename Fn >
39 control_block( context::preallocated, StackAllocator, Fn &&);
41 control_block( typename push_coroutine< T >::control_block *, boost::context::execution_context const&) noexcept;
43 ~control_block() noexcept;
45 control_block( control_block &) = delete;
46 control_block & operator=( control_block &) = delete;
48 void deallocate() noexcept;
56 bool valid() const noexcept;
59 template< typename T >
60 struct pull_coroutine< T & >::control_block {
61 boost::context::execution_context ctx;
62 typename push_coroutine< T & >::control_block * other;
64 std::exception_ptr except;
67 static void destroy( control_block * cb) noexcept;
69 template< typename StackAllocator, typename Fn >
70 control_block( context::preallocated, StackAllocator, Fn &&);
72 control_block( typename push_coroutine< T & >::control_block *, boost::context::execution_context const&) noexcept;
74 ~control_block() noexcept;
76 control_block( control_block &) = delete;
77 control_block & operator=( control_block &) = delete;
79 void deallocate() noexcept;
85 bool valid() const noexcept;
88 struct pull_coroutine< void >::control_block {
89 boost::context::execution_context ctx;
90 push_coroutine< void >::control_block * other;
92 std::exception_ptr except;
94 static void destroy( control_block * cb) noexcept;
96 template< typename StackAllocator, typename Fn >
97 control_block( context::preallocated, StackAllocator, Fn &&);
99 control_block( push_coroutine< void >::control_block *, boost::context::execution_context const&) noexcept;
101 ~control_block() noexcept;
103 control_block( control_block &) = delete;
104 control_block & operator=( control_block &) = delete;
106 void deallocate() noexcept;
110 bool valid() const noexcept;
115 #ifdef BOOST_HAS_ABI_HEADERS
116 # include BOOST_ABI_SUFFIX
119 #endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP