]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/coroutine2/detail/pull_control_block_cc.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / coroutine2 / detail / pull_control_block_cc.hpp
1
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)
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 <type_traits>
12
13 #include <boost/config.hpp>
14 #include <boost/context/continuation.hpp>
15
16 #include <boost/coroutine2/detail/state.hpp>
17
18 #ifdef BOOST_HAS_ABI_HEADERS
19 # include BOOST_ABI_PREFIX
20 #endif
21
22 namespace boost {
23 namespace coroutines2 {
24 namespace detail {
25
26 template< typename T >
27 struct pull_coroutine< T >::control_block {
28 boost::context::continuation c;
29 typename push_coroutine< T >::control_block * other;
30 state_t state;
31 std::exception_ptr except;
32 bool bvalid;
33 typename std::aligned_storage< sizeof( T), alignof( T) >::type storage;
34
35 static void destroy( control_block * cb) noexcept;
36
37 template< typename StackAllocator, typename Fn >
38 control_block( context::preallocated, StackAllocator &&, Fn &&);
39
40 control_block( typename push_coroutine< T >::control_block *, boost::context::continuation &) noexcept;
41
42 ~control_block();
43
44 control_block( control_block &) = delete;
45 control_block & operator=( control_block &) = delete;
46
47 void deallocate() noexcept;
48
49 void resume();
50
51 void set( T const&);
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 struct holder {
62 T & t;
63
64 holder( T & t_) :
65 t{ t_ } {
66 }
67 };
68
69 boost::context::continuation c;
70 typename push_coroutine< T & >::control_block * other;
71 state_t state;
72 std::exception_ptr except;
73 bool bvalid;
74 typename std::aligned_storage< sizeof( holder), alignof( holder) >::type storage;
75
76 static void destroy( control_block * cb) noexcept;
77
78 template< typename StackAllocator, typename Fn >
79 control_block( context::preallocated, StackAllocator &&, Fn &&);
80
81 control_block( typename push_coroutine< T & >::control_block *, boost::context::continuation &) noexcept;
82
83 control_block( control_block &) = delete;
84 control_block & operator=( control_block &) = delete;
85
86 void deallocate() noexcept;
87
88 void resume();
89
90 void set( T &);
91
92 T & get() noexcept;
93
94 bool valid() const noexcept;
95 };
96
97 struct pull_coroutine< void >::control_block {
98 boost::context::continuation c;
99 push_coroutine< void >::control_block * other;
100 state_t state;
101 std::exception_ptr except;
102
103 static void destroy( control_block * cb) noexcept;
104
105 template< typename StackAllocator, typename Fn >
106 control_block( context::preallocated, StackAllocator &&, Fn &&);
107
108 control_block( push_coroutine< void >::control_block *, boost::context::continuation &) noexcept;
109
110 control_block( control_block &) = delete;
111 control_block & operator=( control_block &) = delete;
112
113 void deallocate() noexcept;
114
115 void resume();
116
117 bool valid() const noexcept;
118 };
119
120 }}}
121
122 #ifdef BOOST_HAS_ABI_HEADERS
123 # include BOOST_ABI_SUFFIX
124 #endif
125
126 #endif // BOOST_COROUTINES2_DETAIL_PULL_CONTROL_BLOCK_HPP