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
11 #include <type_traits>
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 pull_coroutine< T >::control_block {
28 boost::context::execution_context< T * > ctx;
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::execution_context< T * > &) noexcept;
44 control_block( control_block &) = delete;
45 control_block & operator=( control_block &) = delete;
47 void deallocate() noexcept;
55 bool valid() const noexcept;
58 template< typename T >
59 struct pull_coroutine< T & >::control_block {
60 boost::context::execution_context< T * > ctx;
61 typename push_coroutine< T & >::control_block * other;
63 std::exception_ptr except;
66 static void destroy( control_block * cb) noexcept;
68 template< typename StackAllocator, typename Fn >
69 control_block( context::preallocated, StackAllocator, Fn &&);
71 control_block( typename push_coroutine< T & >::control_block *, boost::context::execution_context< T * > &) noexcept;
73 control_block( control_block &) = delete;
74 control_block & operator=( control_block &) = delete;
76 void deallocate() noexcept;
82 bool valid() const noexcept;
85 struct pull_coroutine< void >::control_block {
86 boost::context::execution_context< void > ctx;
87 push_coroutine< void >::control_block * other;
89 std::exception_ptr except;
91 static void destroy( control_block * cb) noexcept;
93 template< typename StackAllocator, typename Fn >
94 control_block( context::preallocated, StackAllocator, Fn &&);
96 control_block( push_coroutine< void >::control_block *, boost::context::execution_context< void > &) noexcept;
98 control_block( control_block &) = delete;
99 control_block & operator=( control_block &) = delete;
101 void deallocate() noexcept;
105 bool valid() const noexcept;
110 #ifdef BOOST_HAS_ABI_HEADERS
111 # include BOOST_ABI_SUFFIX
114 #endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP