Skip to content

Commit

Permalink
chore: rename to elastic
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Dec 24, 2023
1 parent b2e7d3a commit 7314afe
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 33 deletions.
8 changes: 4 additions & 4 deletions include/boost/http_proto/impl/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ set_body(
std::decay<ElasticBuffer>::type,
buffers_N>(std::forward<
ElasticBuffer>(eb)));
dyn_ = &dyn;
how_ = how::dynamic;
eb_ = &dyn;
how_ = how::elastic;
on_set_body();
}

Expand All @@ -79,8 +79,8 @@ set_body(
buffers::any_dynamic_buffer_impl<typename
std::decay<ElasticBuffer>::type&,
buffers_N>(eb));
dyn_ = &dyn;
how_ = how::dynamic;
eb_ = &dyn;
how_ = how::elastic;
on_set_body();
}

Expand Down
61 changes: 34 additions & 27 deletions include/boost/http_proto/impl/parser.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ parser(
parser_service>())
, h_(detail::empty{k})
, st_(state::reset)
, eb_(nullptr)
{
auto const n =
svc_.space_needed;
Expand All @@ -249,6 +250,12 @@ void
parser::
reset() noexcept
{
if(eb_)
{
eb_->~any_dynamic_buffer();
eb_ = nullptr;
}

ws_.clear();
st_ = state::start;
got_eof_ = false;
Expand Down Expand Up @@ -404,7 +411,7 @@ prepare() ->
return mutable_buffers_type(mbp_);
}

if(how_ == how::dynamic)
if(how_ == how::elastic)
{
// Overreads are not allowed, or
// else the caller will see extra
Expand All @@ -419,7 +426,7 @@ prepare() ->
if( n > svc_.cfg.max_prepare)
n = svc_.cfg.max_prepare;
nprepare_ = n;
return dyn_->prepare(n);
return eb_->prepare(n);
}

BOOST_ASSERT(
Expand All @@ -434,17 +441,17 @@ prepare() ->
{
// apply max_size()
auto avail =
dyn_->max_size() -
dyn_->size();
eb_->max_size() -
eb_->size();
if( n > avail)
n = avail;
}
// fill capacity() first,
// to avoid an allocation
{
auto avail =
dyn_->capacity() -
dyn_->size();
eb_->capacity() -
eb_->size();
if( n > avail &&
avail != 0)
n = avail;
Expand All @@ -466,7 +473,7 @@ prepare() ->
}
}
nprepare_ = n;
return dyn_->prepare(n);
return eb_->prepare(n);
}

// VFALCO TODO
Expand All @@ -481,7 +488,7 @@ prepare() ->
{
BOOST_ASSERT(is_plain());

if(how_ == how::dynamic)
if(how_ == how::elastic)
{
// attempt to transfer in-place
// body into the dynamic buffer.
Expand Down Expand Up @@ -604,14 +611,14 @@ commit(
break;
}

if(how_ == how::dynamic)
if(how_ == how::elastic)
{
if(dyn_->size() < dyn_->max_size())
if(eb_->size() < eb_->max_size())
{
BOOST_ASSERT(body_avail_ == 0);
BOOST_ASSERT(
body_buf_->size() == 0);
dyn_->commit(n);
eb_->commit(n);
}
else
{
Expand Down Expand Up @@ -659,7 +666,7 @@ commit(

BOOST_ASSERT(is_plain());
BOOST_ASSERT(n == 0);
if( how_ == how::dynamic ||
if( how_ == how::elastic ||
how_ == how::sink)
{
// intended no-op
Expand Down Expand Up @@ -865,7 +872,7 @@ parse(
break;
}

if(how_ == how::dynamic)
if(how_ == how::elastic)
{
// state already updated in commit
if(h_.md.payload == payload::size)
Expand All @@ -876,8 +883,8 @@ parse(
if(body_avail_ != 0)
{
BOOST_ASSERT(
dyn_->max_size() -
dyn_->size() <
eb_->max_size() -
eb_->size() <
payload_remain_);
ec = BOOST_HTTP_PROTO_ERR(
error::buffer_overflow);
Expand All @@ -895,7 +902,7 @@ parse(
}
BOOST_ASSERT(
h_.md.payload == payload::to_eof);
if( dyn_->size() == dyn_->max_size() &&
if( eb_->size() == eb_->max_size() &&
body_avail_ > 0)
{
// got here from the 1-byte read
Expand Down Expand Up @@ -924,7 +931,7 @@ parse(

// transfer in_place data into set body

if(how_ == how::dynamic)
if(how_ == how::elastic)
{
init_dynamic(ec);
if(! ec.failed())
Expand Down Expand Up @@ -1003,13 +1010,13 @@ parse(
case how::in_place:
break;

case how::dynamic:
case how::elastic:
{
if(body_buf_->size() == 0)
break;
BOOST_ASSERT(dyn_->size() == 0);
BOOST_ASSERT(eb_->size() == 0);
auto n = buffers::buffer_copy(
dyn_->prepare(
eb_->prepare(
body_buf_->size()),
body_buf_->data());
body_buf_->consume(n);
Expand Down Expand Up @@ -1245,7 +1252,7 @@ on_set_body()

nprepare_ = 0; // invalidate

if(how_ == how::dynamic)
if(how_ == how::elastic)
{
if(h_.md.payload == payload::none)
{
Expand Down Expand Up @@ -1288,7 +1295,7 @@ init_dynamic(
BOOST_ASSERT(
body_total_ == body_avail_);
auto const space_left =
dyn_->max_size() - dyn_->size();
eb_->max_size() - eb_->size();

if(h_.md.payload == payload::size)
{
Expand All @@ -1299,14 +1306,14 @@ init_dynamic(
return;
}
// reserve the full size
dyn_->prepare(h_.md.payload_size);
eb_->prepare(h_.md.payload_size);
// transfer in-place body
auto n = body_avail_;
if( n > h_.md.payload_size)
n = h_.md.payload_size;
dyn_->commit(
eb_->commit(
buffers::buffer_copy(
dyn_->prepare(n),
eb_->prepare(n),
body_buf_->data()));
BOOST_ASSERT(body_avail_ == n);
BOOST_ASSERT(body_total_ == n);
Expand Down Expand Up @@ -1334,9 +1341,9 @@ init_dynamic(
error::buffer_overflow);
return;
}
dyn_->commit(
eb_->commit(
buffers::buffer_copy(
dyn_->prepare(body_avail_),
eb_->prepare(body_avail_),
body_buf_->data()));
body_buf_->consume(body_avail_);
body_avail_ = 0;
Expand Down
4 changes: 2 additions & 2 deletions include/boost/http_proto/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ class BOOST_SYMBOL_VISIBLE
enum class how
{
in_place,
dynamic,
elastic,
sink,
pull
};
Expand All @@ -398,7 +398,7 @@ class BOOST_SYMBOL_VISIBLE
buffers::circular_buffer cb1_;
buffers::circular_buffer* body_buf_;
buffers::mutable_buffer_pair mbp_;
buffers::any_dynamic_buffer* dyn_;
buffers::any_dynamic_buffer* eb_;
filter* filt_;
sink* sink_;

Expand Down

0 comments on commit 7314afe

Please sign in to comment.