@@ -173,7 +173,14 @@ class LockFreeQueueBase
173173 * @return false If the queue is full or the data could not be pushed
174174 */
175175
176- [[nodiscard]] bool push (const T & data) { return data_queue_.push (data); }
176+ [[nodiscard]] bool push (const T & data)
177+ {
178+ if constexpr (is_spsc_queue<LockFreeContainer>::value) {
179+ return data_queue_.push (data);
180+ } else {
181+ return data_queue_.bounded_push (data);
182+ }
183+ }
177184
178185 /* *
179186 * @brief Push the data into the queue
@@ -185,7 +192,11 @@ class LockFreeQueueBase
185192 template <typename U>
186193 [[nodiscard]] std::enable_if_t <std::is_convertible_v<T, U>, bool > push (const U & data)
187194 {
188- return data_queue_.push (data);
195+ if constexpr (is_spsc_queue<LockFreeContainer>::value) {
196+ return data_queue_.push (data);
197+ } else {
198+ return data_queue_.bounded_push (data);
199+ }
189200 }
190201
191202 /* *
@@ -203,17 +214,10 @@ class LockFreeQueueBase
203214 template <typename U>
204215 [[nodiscard]] std::enable_if_t <std::is_convertible_v<T, U>, bool > bounded_push (const U & data)
205216 {
206- const auto bounded_push = [this ](const U & info) -> bool {
207- if constexpr (is_spsc_queue<LockFreeContainer>::value) {
208- return data_queue_.push (info);
209- } else {
210- return data_queue_.bounded_push (info);
211- }
212- };
213- if (!bounded_push (data)) {
217+ if (!push (data)) {
214218 T dummy;
215219 data_queue_.pop (dummy);
216- return bounded_push (data);
220+ return push (data);
217221 }
218222 return true ;
219223 }
@@ -317,7 +321,9 @@ using LockFreeSPSCQueue = std::conditional_t<
317321 */
318322template <class DataType , std::size_t Capacity = 0 , bool FixedSize = true >
319323using LockFreeMPMCQueue = std::conditional_t <
320- Capacity == 0 , LockFreeQueueBase<DataType, boost::lockfree::queue<DataType>>,
324+ Capacity == 0 ,
325+ LockFreeQueueBase<
326+ DataType, boost::lockfree::queue<DataType, boost::lockfree::fixed_sized<FixedSize>>>,
321327 LockFreeQueueBase<
322328 DataType,
323329 boost::lockfree::queue<
0 commit comments