38#ifndef __BASE_CIRCLEBUF_HH__
39#define __BASE_CIRCLEBUF_HH__
91 template <
class OutputIterator>
93 peek(OutputIterator out,
size_t len)
const
105 template <
class OutputIterator>
110 "Trying to read past end of circular buffer.");
118 const size_t to_end =
buffer.end() - next_it;
123 out = std::copy_n(next_it, to_end, out);
129 std::copy_n(next_it,
len, out);
138 template <
class OutputIterator>
156 template <
class InputIterator>
173 const size_t total_bytes =
used +
len;
174 const size_t overflow = total_bytes >
maxSize ?
179 const size_t to_end =
buffer.end() - next_it;
184 std::copy_n(in, to_end, next_it);
187 std::advance(in, to_end);
192 std::copy_n(in,
len, next_it);
227 template <
class OutputIterator>
229 template <
class OutputIterator>
232 template <
class InputIterator>
251 param.
peek(temp.begin(), temp.size());
263 param.
write(temp.cbegin(), temp.size());
271 param.
peek(temp.begin(), temp.size());
283 "Trying to unserialize data into too small FIFO");
286 param.
write(temp.cbegin(), temp.size());
Circular buffer backed by a vector.
void read(OutputIterator out, size_t len)
Copy buffer contents and advance the read pointer.
void write(InputIterator in, size_t len)
Add elements to the end of the ring buffers and advance.
void peek(OutputIterator out, off_t offset, size_t len) const
Copy buffer contents without advancing the read pointer.
void flush()
Throw away any data in the buffer.
void peek(OutputIterator out, size_t len) const
Copy buffer contents without advancing the read pointer.
Simple FIFO implementation backed by a circular buffer.
void write(InputIterator in, size_t len)
void peek(OutputIterator out, size_t len) const
CircleBuf< value_type > buf
void read(OutputIterator out, size_t len)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
std::ostream CheckpointOut
void arrayParamOut(CheckpointOut &cp, const std::string &name, const CircleBuf< T > ¶m)
void arrayParamIn(CheckpointIn &cp, const std::string &name, CircleBuf< T > ¶m)
const std::string & name()