Commit 2beb763b authored by Max Kellermann's avatar Max Kellermann

util/ForeignFifoBuffer: add method MoveFrom()

parent 69ae879c
......@@ -204,6 +204,22 @@ public:
return n;
}
/**
* Move as much data as possible from the specified buffer.
*
* @return the number of items moved
*/
size_type MoveFrom(ForeignFifoBuffer<T> &src) {
auto r = src.Read();
auto w = Write();
size_t n = std::min(r.size, w.size);
std::move(r.data, r.data + n, w.data);
Append(n);
src.Consume(n);
return n;
}
protected:
void Shift() {
if (head == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment