mirror of
https://github.com/matrix-construct/construct
synced 2024-10-01 13:18:58 +02:00
ircd::buffer: Add window_buffer::rewind(n).
This commit is contained in:
parent
373a791158
commit
b528920420
1 changed files with 11 additions and 0 deletions
|
@ -36,6 +36,7 @@ struct ircd::buffer::window_buffer
|
||||||
mutable_buffer completed();
|
mutable_buffer completed();
|
||||||
|
|
||||||
const_buffer operator()(const closure &closure);
|
const_buffer operator()(const closure &closure);
|
||||||
|
const_buffer rewind(const size_t &n = 1);
|
||||||
|
|
||||||
window_buffer(const mutable_buffer &base);
|
window_buffer(const mutable_buffer &base);
|
||||||
};
|
};
|
||||||
|
@ -46,6 +47,16 @@ ircd::buffer::window_buffer::window_buffer(const mutable_buffer &base)
|
||||||
,base{base}
|
,base{base}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
inline ircd::buffer::const_buffer
|
||||||
|
ircd::buffer::window_buffer::rewind(const size_t &n)
|
||||||
|
{
|
||||||
|
const size_t nmax{std::min(n, consumed())};
|
||||||
|
static_cast<mutable_buffer &>(*this).begin() -= nmax;
|
||||||
|
assert(base.begin() <= begin());
|
||||||
|
assert(begin() <= base.end());
|
||||||
|
return completed();
|
||||||
|
}
|
||||||
|
|
||||||
inline ircd::buffer::const_buffer
|
inline ircd::buffer::const_buffer
|
||||||
ircd::buffer::window_buffer::operator()(const closure &closure)
|
ircd::buffer::window_buffer::operator()(const closure &closure)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue