1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <bits/ios_base.h>
21
22 namespace jmmcg {
23
24
25
26
27
28 template<
29 class Colln,
30 unsigned long I
31 >
32 struct front_batch : public Colln {
33 static constexpr unsigned long max_size=I;
34 typedef Colln base_t;
35 typedef typename base_t::thread_traits thread_traits;
36 typedef Colln container_type;
37 typedef typename container_type::value_ret_type value_ret_type;
38 typedef typename container_type::exception_type exeception_type;
39
40 static_assert(max_size>1UL, "Wrong batch size.");
41
42 constexpr front_batch() noexcept(noexcept(base_t()))
43 : base_t() {}
44 explicit front_batch(typename base_t::have_work_type::atomic_t &a) noexcept(noexcept(base_t(std::declval<base_t>())))
45 : base_t(a) {}
46 front_batch(front_batch const &fb) noexcept(noexcept(base_t(std::declval<front_batch>())))
47 : base_t(fb) {}
48 front_batch &__fastcall FORCE_INLINE operator=(front_batch const &fb) noexcept(noexcept(base_t::operator=(std::declval<front_batch>()))) {
49 base_t::operator=(fb);
50 return *this;
51 }
52
53
54
55
56
57
58
59 value_ret_type __fastcall pop_front_nochk_nolk() noexcept(true) FORCE_INLINE;
60 };
61
62
63 template<
64 class Colln
65 >
66 class front_batch<Colln, 0UL> : public Colln {
67 };
68
69
70 template<
71 class Colln
72 >
73 struct front_batch<Colln, 1UL> : public Colln {
74 static constexpr unsigned long max_size=1UL;
75 typedef Colln base_t;
76 typedef typename base_t::thread_traits thread_traits;
77 typedef Colln container_type;
78 typedef typename container_type::value_ret_type value_ret_type;
79
80 constexpr front_batch() noexcept(noexcept(base_t()))
81 : base_t() {}
82 explicit front_batch(typename base_t::have_work_type::atomic_t &a) noexcept(noexcept(base_t(a)))
83 : base_t(a) {}
84 front_batch(front_batch const &fb) noexcept(noexcept(base_t(std::declval<front_batch>())))
85 : base_t(fb) {}
86 front_batch &__fastcall FORCE_INLINE operator=(front_batch const &fb) noexcept(noexcept(base_t::operator=(std::declval<front_batch>()))) {
87 base_t::operator=(fb);
88 return *this;
89 }
90
91 value_ret_type __fastcall pop_front_nochk_nolk() noexcept(true);
92 };
93
94
95
96
97
98 template<
99 class Colln,
100 unsigned long I
101 >
102 struct back_batch final : public front_batch<Colln, I> {
103 typedef front_batch<Colln, I> base_t;
104 using base_t::max_size;
105 typedef typename base_t::thread_traits thread_traits;
106 typedef typename base_t::container_type container_type;
107 typedef typename container_type::value_type value_type;
108 typedef typename container_type::exception_type exception_type;
109
110 static_assert(max_size>1UL, "Wrong batch size.");
111
112 constexpr back_batch() noexcept(noexcept(base_t()))
113 : base_t() {}
114 explicit back_batch(typename base_t::have_work_type::atomic_t &a) noexcept(noexcept(base_t(a)))
115 : base_t(a) {}
116
117
118
119
120
121
122
123
124
125
126
127 };
128
129
130 template<
131 class Colln
132 >
133 class back_batch<Colln, 0UL> final : public front_batch<Colln, 0UL> {
134 };
135
136
137 template<
138 class Colln
139 >
140 struct back_batch<Colln, 1UL> final : public front_batch<Colln, 1UL> {
141 typedef front_batch<Colln, 1UL> base_t;
142 using base_t::max_size;
143 typedef typename base_t::thread_traits thread_traits;
144 typedef typename base_t::container_type container_type;
145 typedef typename container_type::value_type value_type;
146 typedef typename container_type::exception_type exception_type;
147
148 constexpr back_batch() noexcept(noexcept(base_t()))
149 : base_t() {}
150 explicit back_batch(typename base_t::have_work_type::atomic_t &a) noexcept(noexcept(base_t(a)))
151 : base_t(a) {}
152 back_batch(back_batch const &bb) noexcept(noexcept(base_t(std::declval<back_batch>())))
153 : base_t(bb) {}
154 back_batch &__fastcall FORCE_INLINE operator=(back_batch const &bb) noexcept(noexcept(base_t::operator=(std::declval<back_batch>()))) {
155 base_t::operator=(bb);
156 return *this;
157 }
158
159 void __fastcall push_back(const value_type &data_item) noexcept(false) FORCE_INLINE;
160 void __fastcall push_back(value_type &&data_item) noexcept(false) FORCE_INLINE;
161 void __fastcall push(const value_type &data_item) noexcept(false) FORCE_INLINE;
162 void __fastcall push(value_type &&data_item) noexcept(false) FORCE_INLINE;
163 };
164
165 }
166
167 #include "batch_impl.hpp"