diff --git a/src/circular_queue/MultiDelegate.h b/src/circular_queue/MultiDelegate.h index d84c4c3..58af232 100644 --- a/src/circular_queue/MultiDelegate.h +++ b/src/circular_queue/MultiDelegate.h @@ -87,7 +87,7 @@ namespace detail }; }; - template< typename Delegate, typename R = void, bool ISQUEUE = false, unsigned QUEUE_CAPACITY = 32, typename... P> + template< typename Delegate, typename R = void, bool ISQUEUE = false, size_t QUEUE_CAPACITY = 32, typename... P> class MultiDelegatePImpl { public: @@ -176,7 +176,7 @@ namespace detail Node_t* first = nullptr; Node_t* last = nullptr; Node_t* unused = nullptr; - unsigned nodeCount = 0; + size_t nodeCount = 0; // Returns a pointer to an unused Node_t, // or if none are available allocates a new one, @@ -370,7 +370,7 @@ namespace detail } }; - template< typename Delegate, typename R = void, bool ISQUEUE = false, unsigned QUEUE_CAPACITY = 32> + template< typename Delegate, typename R = void, bool ISQUEUE = false, size_t QUEUE_CAPACITY = 32> class MultiDelegateImpl : public MultiDelegatePImpl { protected: @@ -456,16 +456,16 @@ namespace detail } }; - template< typename Delegate, typename R, bool ISQUEUE, unsigned QUEUE_CAPACITY, typename... P> class MultiDelegate; + template< typename Delegate, typename R, bool ISQUEUE, size_t QUEUE_CAPACITY, typename... P> class MultiDelegate; - template< typename Delegate, typename R, bool ISQUEUE, unsigned QUEUE_CAPACITY, typename... P> + template< typename Delegate, typename R, bool ISQUEUE, size_t QUEUE_CAPACITY, typename... P> class MultiDelegate : public MultiDelegatePImpl { public: using MultiDelegatePImpl::MultiDelegatePImpl; }; - template< typename Delegate, typename R, bool ISQUEUE, unsigned QUEUE_CAPACITY> + template< typename Delegate, typename R, bool ISQUEUE, size_t QUEUE_CAPACITY> class MultiDelegate : public MultiDelegateImpl { public: @@ -493,7 +493,7 @@ It is designed to be used with Delegate, the efficient runtime wrapper for C fun allocates from the heap. Unused items are not returned to the heap, but are managed by the MultiDelegate instance during its own lifetime for efficiency. */ -template< typename Delegate, bool ISQUEUE = false, unsigned QUEUE_CAPACITY = 32> +template< typename Delegate, bool ISQUEUE = false, size_t QUEUE_CAPACITY = 32> class MultiDelegate : public detail::MultiDelegate { public: diff --git a/src/circular_queue/circular_queue.h b/src/circular_queue/circular_queue.h index 46e3f66..e4fad8e 100644 --- a/src/circular_queue/circular_queue.h +++ b/src/circular_queue/circular_queue.h @@ -224,14 +224,14 @@ class circular_queue protected: const T defaultValue = {}; - unsigned m_bufSize; + size_t m_bufSize; #if defined(ESP8266) || defined(ESP32) || !defined(ARDUINO) std::unique_ptr m_buffer; #else std::unique_ptr m_buffer; #endif - std::atomic m_inPos; - std::atomic m_outPos; + std::atomic m_inPos; + std::atomic m_outPos; }; template< typename T, typename ForEachArg > @@ -253,7 +253,7 @@ template< typename T, typename ForEachArg > bool IRAM_ATTR circular_queue::push() { const auto inPos = m_inPos.load(std::memory_order_acquire); - const unsigned next = (inPos + 1) % m_bufSize; + const size_t next = (inPos + 1) % m_bufSize; if (next == m_outPos.load(std::memory_order_relaxed)) { return false; } @@ -268,7 +268,7 @@ template< typename T, typename ForEachArg > bool IRAM_ATTR circular_queue::push(T&& val) { const auto inPos = m_inPos.load(std::memory_order_acquire); - const unsigned next = (inPos + 1) % m_bufSize; + const size_t next = (inPos + 1) % m_bufSize; if (next == m_outPos.load(std::memory_order_relaxed)) { return false; } diff --git a/src/circular_queue/ghostl.h b/src/circular_queue/ghostl.h index 1168380..50f522c 100644 --- a/src/circular_queue/ghostl.h +++ b/src/circular_queue/ghostl.h @@ -26,6 +26,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif +using size_t = decltype(sizeof(char)); + namespace std { #if !defined(ARDUINO_ARCH_SAMD) @@ -48,7 +50,7 @@ namespace std template< typename T > T&& move(T& t) noexcept { return static_cast(t); } #endif - template< typename T, unsigned long N > struct array + template< typename T, size_t long N > struct array { T _M_elems[N]; decltype(sizeof(0)) size() const { return N; }