This commit is contained in:
Adam Ierymenko 2019-08-20 15:36:18 -07:00
parent 3a21fdc304
commit fe8815f80f
No known key found for this signature in database
GPG key ID: 1657198823E52A61

View file

@ -40,13 +40,12 @@ namespace ZeroTier {
* A circular buffer * A circular buffer
* *
* For fast handling of continuously-evolving variables (such as path quality metrics). * For fast handling of continuously-evolving variables (such as path quality metrics).
* Using this, we can maintain longer sliding historical windows for important path * Using this, we can maintain longer sliding historical windows for important path
* metrics without the need for potentially expensive calls to memcpy/memmove. * metrics without the need for potentially expensive calls to memcpy/memmove.
* *
* Some basic statistical functionality is implemented here in an attempt * Some basic statistical functionality is implemented here in an attempt
* to reduce the complexity of code needed to interact with this type of buffer. * to reduce the complexity of code needed to interact with this type of buffer.
*/ */
template <class T,size_t S> template <class T,size_t S>
class RingBuffer class RingBuffer
{ {
@ -73,7 +72,7 @@ public:
return buf + begin; return buf + begin;
} }
/** /**
* Adjust buffer index pointer as if we copied data in * Adjust buffer index pointer as if we copied data in
* @param n Number of elements to copy in * @param n Number of elements to copy in
* @return Number of elements we copied in * @return Number of elements we copied in
@ -96,13 +95,13 @@ public:
return n; return n;
} }
/** /**
* Fast erase, O(1). * Fast erase, O(1).
* Merely reset the buffer pointer, doesn't erase contents * Merely reset the buffer pointer, doesn't erase contents
*/ */
inline void reset() { consume(count()); } inline void reset() { consume(count()); }
/** /**
* adjust buffer index pointer as if we copied data out * adjust buffer index pointer as if we copied data out
* @param n Number of elements we copied from the buffer * @param n Number of elements we copied from the buffer
* @return Number of elements actually available from the buffer * @return Number of elements actually available from the buffer