util/ForeignFifoBuffer: add method MoveFrom()
This commit is contained in:
parent
69ae879c58
commit
2beb763b4f
@ -204,6 +204,22 @@ public:
|
|||||||
return n;
|
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:
|
protected:
|
||||||
void Shift() {
|
void Shift() {
|
||||||
if (head == 0)
|
if (head == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user