@@ -19,15 +19,15 @@ namespace xtxn {
1919 int32_t S = queue_default_block_size,
2020 int32_t L = queue_default_capacity_limit,
2121 bool C = queue_default_completion,
22- int32_t A = queue_default_attempts,
22+ unsigned A = queue_default_attempts,
2323 queue_growth_policy G = queue_growth_policy::round
2424 >
2525 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
2626 class alignas (queue_alignment) fast_mpmc_queue {
2727 struct slot ;
2828 struct block ;
2929 using slot_completion = queue_slot_completion<C>;
30- // class base_accessor;
30+ // class base_accessor; // CLEANUP
3131 class producer_accessor ;
3232 class consumer_accessor ;
3333 using mo = std::memory_order;
@@ -52,8 +52,8 @@ namespace xtxn {
5252
5353 static constexpr size_type c_block_size [[maybe_unused]] { S };
5454 static constexpr size_type c_max_capacity [[maybe_unused]] { L };
55- static constexpr bool c_auto_complete [[maybe_unused]] { slot_completion::c_auto_complete };
56- static constexpr int32_t c_default_attempts [[maybe_unused]] { A };
55+ static constexpr bool c_auto_complete [[maybe_unused]] { C };
56+ static constexpr unsigned c_default_attempts [[maybe_unused]] { A };
5757 static constexpr queue_growth_policy c_growth_policy [[maybe_unused]] { G };
5858
5959 fast_mpmc_queue () noexcept (c_ntdct);
@@ -89,8 +89,8 @@ namespace xtxn {
8989 return m_consuming.load (mo::relaxed);
9090 }
9191
92- [[nodiscard]] producer_accessor producer_slot (int32_t = c_default_attempts) noexcept (c_ntdct);
93- [[nodiscard]] consumer_accessor consumer_slot (int32_t = c_default_attempts) noexcept ;
92+ [[nodiscard]] producer_accessor producer_slot (unsigned = c_default_attempts) noexcept (c_ntdct);
93+ [[nodiscard]] consumer_accessor consumer_slot (unsigned = c_default_attempts) noexcept ;
9494
9595 [[maybe_unused]]
9696 void shutdown () noexcept {
@@ -104,7 +104,7 @@ namespace xtxn {
104104 }
105105 };
106106
107- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
107+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
108108 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
109109 struct fast_mpmc_queue <T, S, L, C, A, G>::slot {
110110 slot * m_next { nullptr };
@@ -120,7 +120,7 @@ namespace xtxn {
120120 slot & operator =(slot &&) = delete ;
121121 };
122122
123- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
123+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
124124 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
125125 struct fast_mpmc_queue <T, S, L, C, A, G>::block {
126126 std::array<slot, static_cast <size_t >(S)> m_slots {};
@@ -146,7 +146,7 @@ namespace xtxn {
146146 }
147147 };
148148
149- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
149+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
150150 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
151151 fast_mpmc_queue<T, S, L, C, A, G>::block::block() noexcept (c_ntdct) {
152152 auto it = m_slots.begin ();
@@ -160,7 +160,7 @@ namespace xtxn {
160160 last->m_next = &m_slots[0 ];
161161 }
162162
163- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
163+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
164164 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
165165 fast_mpmc_queue<T, S, L, C, A, G>::block::block(block * & last_block) noexcept (c_ntdct) {
166166 assert (last_block);
@@ -178,7 +178,8 @@ namespace xtxn {
178178 last_block->m_next = this ;
179179 }
180180
181- // template<std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
181+ // CLEANUP
182+ // template<std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
182183 // requires ((S >= 4) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0) && (A <= queue_max_attempts))
183184 // class fast_mpmc_queue<T, S, L, C, A, G>::base_accessor {
184185 // protected:
@@ -209,12 +210,12 @@ namespace xtxn {
209210 // }
210211 // };
211212
212- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
213+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
213214 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
214215 class fast_mpmc_queue <T, S, L, C, A, G>::producer_accessor : /* public base_accessor,*/ public slot_completion {
215216 protected:
216- // using base_accessor::m_queue;
217- // using base_accessor::m_slot;
217+ // using base_accessor::m_queue; // CLEANUP
218+ // using base_accessor::m_slot; // CLEANUP
218219 fast_mpmc_queue & m_queue;
219220 slot * const m_slot;
220221
@@ -251,7 +252,7 @@ namespace xtxn {
251252 }
252253 };
253254
254- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
255+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
255256 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
256257 fast_mpmc_queue<T, S, L, C, A, G>::producer_accessor::~producer_accessor () noexcept {
257258 if (m_slot) {
@@ -268,12 +269,12 @@ namespace xtxn {
268269 }
269270 }
270271
271- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
272+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
272273 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
273274 class fast_mpmc_queue <T, S, L, C, A, G>::consumer_accessor : /* public base_accessor,*/ public slot_completion {
274275 protected:
275- // using base_accessor::m_queue;
276- // using base_accessor::m_slot;
276+ // using base_accessor::m_queue; // CLEANUP
277+ // using base_accessor::m_slot; // CLEANUP
277278 fast_mpmc_queue & m_queue;
278279 slot * const m_slot;
279280
@@ -306,7 +307,7 @@ namespace xtxn {
306307 }
307308 };
308309
309- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
310+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
310311 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
311312 fast_mpmc_queue<T, S, L, C, A, G>::consumer_accessor::~consumer_accessor () noexcept {
312313 if (m_slot) {
@@ -324,7 +325,7 @@ namespace xtxn {
324325 }
325326 }
326327
327- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
328+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
328329 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
329330 fast_mpmc_queue<T, S, L, C, A, G>::fast_mpmc_queue() noexcept (c_ntdct)
330331 : m_first_block { new block }, m_last_block { m_first_block } {
@@ -333,15 +334,15 @@ namespace xtxn {
333334 m_consumer_cursor.store (first_slot, mo::relaxed);
334335 }
335336
336- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
337+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
337338 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
338- auto fast_mpmc_queue<T, S, L, C, A, G>::producer_slot(int32_t slot_acquire_attempts)
339+ auto fast_mpmc_queue<T, S, L, C, A, G>::producer_slot(unsigned slot_acquire_attempts)
339340 noexcept (c_ntdct) -> producer_accessor {
340341 if (!m_free.load (mo::acquire) && !grow ()) {
341342 return { *this , nullptr };
342343 }
343344
344- int_fast32_t attempts { slot_acquire_attempts - 1 };
345+ unsigned attempts { slot_acquire_attempts - 1 };
345346 slot * sentinel { m_producer_cursor.exchange (m_producer_cursor.load (mo::acquire)->m_next , mo::acq_rel) };
346347 slot * current { sentinel };
347348
@@ -372,10 +373,11 @@ namespace xtxn {
372373 return { *this , nullptr };
373374 }
374375
375- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
376+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
376377 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
377- auto fast_mpmc_queue<T, S, L, C, A, G>::consumer_slot(int32_t slot_acquire_attempts) noexcept -> consumer_accessor {
378- int_fast32_t attempts { slot_acquire_attempts - 1 };
378+ auto fast_mpmc_queue<T, S, L, C, A, G>::consumer_slot(unsigned slot_acquire_attempts)
379+ noexcept -> consumer_accessor {
380+ unsigned attempts { slot_acquire_attempts - 1 };
379381 slot * sentinel { m_consumer_cursor.exchange (m_consumer_cursor.load (mo::acquire)->m_next , mo::acq_rel) };
380382 slot * current { sentinel };
381383
@@ -397,7 +399,7 @@ namespace xtxn {
397399 return { *this , nullptr };
398400 }
399401
400- template <std::default_initializable T, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
402+ template <std::default_initializable T, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
401403 requires ((S >= 4 ) && (L <= queue_max_capacity_limit) && (S <= L) && (A > 0 ) && (A <= queue_max_attempts))
402404 bool fast_mpmc_queue<T, S, L, C, A, G>::grow() noexcept (c_ntdct) {
403405 scoped_lock lock { m_spinlock };
@@ -422,7 +424,7 @@ namespace xtxn {
422424
423425 template <class T >
424426 concept fast_mpmc_queue_tc = requires (T t) {
425- [] <std::default_initializable U, int32_t S, int32_t L, bool C, int32_t A, queue_growth_policy G>
427+ [] <std::default_initializable U, int32_t S, int32_t L, bool C, unsigned A, queue_growth_policy G>
426428 (fast_mpmc_queue<U, S, L, C, A, G> &) {} (t);
427429 };
428430}
0 commit comments