]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
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) | |
6 | ||
7 | #ifndef BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP | |
8 | #define BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP | |
9 | ||
10 | #include <exception> | |
11 | #include <functional> | |
12 | #include <type_traits> | |
13 | ||
14 | #include <boost/config.hpp> | |
15 | #include <boost/context/execution_context.hpp> | |
16 | ||
17 | #include <boost/coroutine2/detail/state.hpp> | |
18 | ||
19 | #ifdef BOOST_HAS_ABI_HEADERS | |
20 | # include BOOST_ABI_PREFIX | |
21 | #endif | |
22 | ||
23 | namespace boost { | |
24 | namespace coroutines2 { | |
25 | namespace detail { | |
26 | ||
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; | |
31 | state_t state; | |
32 | std::exception_ptr except; | |
33 | bool bvalid; | |
34 | typename std::aligned_storage< sizeof( T), alignof( T) >::type storage; | |
35 | ||
36 | static void destroy( control_block * cb) noexcept; | |
37 | ||
38 | template< typename StackAllocator, typename Fn > | |
39 | control_block( context::preallocated, StackAllocator, Fn &&); | |
40 | ||
41 | control_block( typename push_coroutine< T >::control_block *, boost::context::execution_context const&) noexcept; | |
42 | ||
43 | ~control_block() noexcept; | |
44 | ||
45 | control_block( control_block &) = delete; | |
46 | control_block & operator=( control_block &) = delete; | |
47 | ||
48 | void deallocate() noexcept; | |
49 | ||
50 | void resume(); | |
51 | ||
52 | void set( T *); | |
53 | ||
54 | T & get() noexcept; | |
55 | ||
56 | bool valid() const noexcept; | |
57 | }; | |
58 | ||
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; | |
63 | state_t state; | |
64 | std::exception_ptr except; | |
65 | T * t; | |
66 | ||
67 | static void destroy( control_block * cb) noexcept; | |
68 | ||
69 | template< typename StackAllocator, typename Fn > | |
70 | control_block( context::preallocated, StackAllocator, Fn &&); | |
71 | ||
72 | control_block( typename push_coroutine< T & >::control_block *, boost::context::execution_context const&) noexcept; | |
73 | ||
74 | ~control_block() noexcept; | |
75 | ||
76 | control_block( control_block &) = delete; | |
77 | control_block & operator=( control_block &) = delete; | |
78 | ||
79 | void deallocate() noexcept; | |
80 | ||
81 | void resume(); | |
82 | ||
83 | T & get() noexcept; | |
84 | ||
85 | bool valid() const noexcept; | |
86 | }; | |
87 | ||
88 | struct pull_coroutine< void >::control_block { | |
89 | boost::context::execution_context ctx; | |
90 | push_coroutine< void >::control_block * other; | |
91 | state_t state; | |
92 | std::exception_ptr except; | |
93 | ||
94 | static void destroy( control_block * cb) noexcept; | |
95 | ||
96 | template< typename StackAllocator, typename Fn > | |
97 | control_block( context::preallocated, StackAllocator, Fn &&); | |
98 | ||
99 | control_block( push_coroutine< void >::control_block *, boost::context::execution_context const&) noexcept; | |
100 | ||
101 | ~control_block() noexcept; | |
102 | ||
103 | control_block( control_block &) = delete; | |
104 | control_block & operator=( control_block &) = delete; | |
105 | ||
106 | void deallocate() noexcept; | |
107 | ||
108 | void resume(); | |
109 | ||
110 | bool valid() const noexcept; | |
111 | }; | |
112 | ||
113 | }}} | |
114 | ||
115 | #ifdef BOOST_HAS_ABI_HEADERS | |
116 | # include BOOST_ABI_SUFFIX | |
117 | #endif | |
118 | ||
119 | #endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP |