Skip to content

Commit f4fbf2f

Browse files
committed
circular_queue Windows portability fix - included for version consistency
1 parent 59df727 commit f4fbf2f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

libraries/FastScheduler/src/circular_queue/circular_queue.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3333
#define IRAM_ATTR
3434
#endif
3535

36+
using std::min;
37+
3638
/*!
3739
@brief Instance class for a single-producer, single-consumer circular queue / ring buffer (FIFO).
3840
This implementation is lock-free between producer and consumer for the available(), peek(),
@@ -236,15 +238,15 @@ size_t circular_queue<T>::push_n(const T* buffer, size_t size)
236238
const auto outPos = m_outPos.load(std::memory_order_relaxed);
237239

238240
size_t blockSize = (outPos > inPos) ? outPos - 1 - inPos : (outPos == 0) ? m_bufSize - 1 - inPos : m_bufSize - inPos;
239-
blockSize = std::min(size, blockSize);
241+
blockSize = min(size, blockSize);
240242
if (!blockSize) return 0;
241243
int next = (inPos + blockSize) % m_bufSize;
242244

243245
std::atomic_thread_fence(std::memory_order_acquire);
244246

245247
auto dest = m_buffer.get() + inPos;
246248
std::copy_n(std::make_move_iterator(buffer), blockSize, dest);
247-
size = std::min(size - blockSize, outPos > 1 ? static_cast<size_t>(outPos - next - 1) : 0);
249+
size = min(size - blockSize, outPos > 1 ? static_cast<size_t>(outPos - next - 1) : 0);
248250
next += size;
249251
dest = m_buffer.get();
250252
std::copy_n(std::make_move_iterator(buffer + blockSize), size, dest);
@@ -273,10 +275,10 @@ T circular_queue<T>::pop()
273275

274276
template< typename T >
275277
size_t circular_queue<T>::pop_n(T* buffer, size_t size) {
276-
size_t avail = size = std::min(size, available());
278+
size_t avail = size = min(size, available());
277279
if (!avail) return 0;
278280
const auto outPos = m_outPos.load(std::memory_order_acquire);
279-
size_t n = std::min(avail, static_cast<size_t>(m_bufSize - outPos));
281+
size_t n = min(avail, static_cast<size_t>(m_bufSize - outPos));
280282

281283
std::atomic_thread_fence(std::memory_order_acquire);
282284

0 commit comments

Comments
 (0)