Skip to content

Commit 84223ea

Browse files
committed
chore: services in polystore
1 parent b19b4d3 commit 84223ea

13 files changed

Lines changed: 91 additions & 95 deletions

include/boost/http_proto/parser.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <boost/buffers/dynamic_buffer.hpp>
2222
#include <boost/buffers/buffer_pair.hpp>
2323
#include <boost/core/span.hpp>
24-
#include <boost/rts/context_fwd.hpp>
24+
#include <boost/rts/polystore_fwd.hpp>
2525

2626
#include <cstddef>
2727
#include <cstdint>
@@ -617,7 +617,7 @@ class parser
617617
BOOST_HTTP_PROTO_DECL ~parser();
618618
BOOST_HTTP_PROTO_DECL parser() noexcept;
619619
BOOST_HTTP_PROTO_DECL parser(parser&& other) noexcept;
620-
BOOST_HTTP_PROTO_DECL parser(rts::context const&, detail::kind);
620+
BOOST_HTTP_PROTO_DECL parser(rts::polystore&, detail::kind);
621621
BOOST_HTTP_PROTO_DECL void assign(parser&& other) noexcept;
622622

623623
BOOST_HTTP_PROTO_DECL
@@ -769,7 +769,7 @@ struct parser::config_base
769769
BOOST_HTTP_PROTO_DECL
770770
void
771771
install_parser_service(
772-
rts::context& ctx,
772+
rts::polystore& ctx,
773773
parser::config_base const& cfg);
774774

775775
} // http_proto

include/boost/http_proto/request_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class request_parser
140140
*/
141141
BOOST_HTTP_PROTO_DECL
142142
explicit
143-
request_parser(rts::context const& ctx);
143+
request_parser(rts::polystore& ctx);
144144

145145
/** Return a reference to the parsed request headers.
146146

include/boost/http_proto/response_parser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class response_parser
140140
*/
141141
BOOST_HTTP_PROTO_DECL
142142
explicit
143-
response_parser(rts::context const& ctx);
143+
response_parser(rts::polystore& ctx);
144144

145145
/** Prepare for the next message on the stream.
146146

include/boost/http_proto/serializer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <boost/buffers/buffer_pair.hpp>
1919
#include <boost/core/span.hpp>
20-
#include <boost/rts/context_fwd.hpp>
20+
#include <boost/rts/polystore_fwd.hpp>
2121
#include <boost/system/result.hpp>
2222

2323
#include <type_traits>
@@ -171,7 +171,7 @@ class serializer
171171
BOOST_HTTP_PROTO_DECL
172172
explicit
173173
serializer(
174-
const rts::context& ctx);
174+
rts::polystore& ctx);
175175

176176
/** Reset the serializer for a new message.
177177
@@ -668,7 +668,7 @@ struct serializer::config
668668
BOOST_HTTP_PROTO_DECL
669669
void
670670
install_serializer_service(
671-
rts::context& ctx,
671+
rts::polystore& ctx,
672672
serializer::config const& cfg);
673673

674674
//------------------------------------------------

src/parser.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <boost/buffers/front.hpp>
2222
#include <boost/buffers/slice.hpp>
2323
#include <boost/rts/brotli/decode.hpp>
24-
#include <boost/rts/context.hpp>
24+
#include <boost/rts/polystore.hpp>
2525
#include <boost/rts/zlib/error.hpp>
2626
#include <boost/rts/zlib/inflate.hpp>
2727
#include <boost/url/grammar/ci_string.hpp>
@@ -309,11 +309,11 @@ class zlib_filter
309309

310310
public:
311311
zlib_filter(
312-
const rts::context& ctx,
312+
const rts::polystore& ctx,
313313
http_proto::detail::workspace& ws,
314314
int window_bits)
315315
: zlib_filter_base(ws)
316-
, svc_(ctx.get_service<rts::zlib::inflate_service>())
316+
, svc_(ctx.get<rts::zlib::inflate_service>())
317317
{
318318
system::error_code ec = static_cast<rts::zlib::error>(
319319
svc_.init2(strm_, window_bits));
@@ -359,9 +359,9 @@ class brotli_filter
359359

360360
public:
361361
brotli_filter(
362-
const rts::context& ctx,
362+
const rts::polystore& ctx,
363363
http_proto::detail::workspace&)
364-
: svc_(ctx.get_service<rts::brotli::decode_service>())
364+
: svc_(ctx.get<rts::brotli::decode_service>())
365365
{
366366
// TODO: use custom allocator
367367
state_ = svc_.create_instance(nullptr, nullptr, nullptr);
@@ -413,15 +413,13 @@ class brotli_filter
413413
};
414414

415415
class parser_service
416-
: public rts::service
417416
{
418417
public:
419418
parser::config_base cfg;
420419
std::size_t space_needed = 0;
421420
std::size_t max_codec = 0;
422421

423422
parser_service(
424-
const rts::context&,
425423
parser::config_base const& cfg_)
426424
: cfg(cfg_)
427425
{
@@ -507,10 +505,10 @@ class parser_service
507505

508506
void
509507
install_parser_service(
510-
rts::context& ctx,
508+
rts::polystore& ctx,
511509
parser::config_base const& cfg)
512510
{
513-
ctx.make_service<parser_service>(cfg);
511+
ctx.emplace<parser_service>(cfg);
514512
}
515513

516514
//------------------------------------------------
@@ -536,7 +534,7 @@ class parser::impl
536534
elastic,
537535
};
538536

539-
const rts::context& ctx_;
537+
const rts::polystore& ctx_;
540538
parser_service& svc_;
541539

542540
detail::workspace ws_;
@@ -569,9 +567,9 @@ class parser::impl
569567
bool chunked_body_ended;
570568

571569
public:
572-
impl(const rts::context& ctx, detail::kind k)
570+
impl(const rts::polystore& ctx, detail::kind k)
573571
: ctx_(ctx)
574-
, svc_(ctx.get_service<parser_service>())
572+
, svc_(ctx.get<parser_service>())
575573
, ws_(svc_.space_needed)
576574
, m_(ws_.data(), ws_.size())
577575
, state_(state::reset)
@@ -1868,7 +1866,7 @@ parser(parser&& other) noexcept
18681866

18691867
parser::
18701868
parser(
1871-
rts::context const& ctx,
1869+
rts::polystore& ctx,
18721870
detail::kind k)
18731871
: impl_(new impl(ctx, k))
18741872
{

src/request_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace http_proto {
1414

1515
request_parser::
1616
request_parser(
17-
const rts::context& ctx)
17+
rts::polystore& ctx)
1818
: parser(
1919
ctx,
2020
detail::kind::request)

src/response_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace http_proto {
1414

1515
response_parser::
1616
response_parser(
17-
const rts::context& ctx)
17+
rts::polystore& ctx)
1818
: parser(
1919
ctx,
2020
detail::kind::response)

src/serializer.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <boost/core/bit.hpp>
2525
#include <boost/core/ignore_unused.hpp>
2626
#include <boost/rts/brotli/encode.hpp>
27-
#include <boost/rts/context.hpp>
27+
#include <boost/rts/polystore.hpp>
2828
#include <boost/rts/zlib/compression_method.hpp>
2929
#include <boost/rts/zlib/compression_strategy.hpp>
3030
#include <boost/rts/zlib/deflate.hpp>
@@ -94,13 +94,13 @@ class zlib_filter
9494

9595
public:
9696
zlib_filter(
97-
const rts::context& ctx,
97+
const rts::polystore& ctx,
9898
http_proto::detail::workspace& ws,
9999
int comp_level,
100100
int window_bits,
101101
int mem_level)
102102
: zlib_filter_base(ws)
103-
, svc_(ctx.get_service<rts::zlib::deflate_service>())
103+
, svc_(ctx.get<rts::zlib::deflate_service>())
104104
{
105105
system::error_code ec = static_cast<rts::zlib::error>(svc_.init2(
106106
strm_,
@@ -160,11 +160,11 @@ class brotli_filter
160160

161161
public:
162162
brotli_filter(
163-
const rts::context& ctx,
163+
const rts::polystore& ctx,
164164
http_proto::detail::workspace&,
165165
std::uint32_t comp_quality,
166166
std::uint32_t comp_window)
167-
: svc_(ctx.get_service<rts::brotli::encode_service>())
167+
: svc_(ctx.get<rts::brotli::encode_service>())
168168
{
169169
// TODO: use custom allocator
170170
state_ = svc_.create_instance(nullptr, nullptr, nullptr);
@@ -231,14 +231,12 @@ clamp(
231231
}
232232

233233
class serializer_service
234-
: public rts::service
235234
{
236235
public:
237236
serializer::config cfg;
238237
std::size_t space_needed = 0;
239238

240239
serializer_service(
241-
const rts::context&,
242240
serializer::config const& cfg_)
243241
: cfg(cfg_)
244242
{
@@ -269,10 +267,10 @@ class serializer_service
269267

270268
void
271269
install_serializer_service(
272-
rts::context& ctx,
270+
rts::polystore& ctx,
273271
serializer::config const& cfg)
274272
{
275-
ctx.make_service<serializer_service>(cfg);
273+
ctx.emplace<serializer_service>(cfg);
276274
}
277275

278276
//------------------------------------------------
@@ -297,7 +295,7 @@ class serializer::impl
297295
stream
298296
};
299297

300-
const rts::context& ctx_;
298+
const rts::polystore& ctx_;
301299
serializer_service& svc_;
302300
detail::workspace ws_;
303301

@@ -319,9 +317,9 @@ class serializer::impl
319317
bool filter_done_ = false;
320318

321319
public:
322-
impl(const rts::context& ctx)
320+
impl(const rts::polystore& ctx)
323321
: ctx_(ctx)
324-
, svc_(ctx_.get_service<serializer_service>())
322+
, svc_(ctx_.get<serializer_service>())
325323
, ws_(svc_.space_needed)
326324
{
327325
}
@@ -957,7 +955,7 @@ operator=(serializer&& other) noexcept
957955
}
958956

959957
serializer::
960-
serializer(rts::context const& ctx)
958+
serializer(rts::polystore& ctx)
961959
: impl_(new impl(ctx))
962960
{
963961
// TODO: use a single allocation for

test/unit/compression.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <boost/core/detail/string_view.hpp>
1717
#include <boost/core/span.hpp>
1818
#include <boost/rts/brotli.hpp>
19-
#include <boost/rts/context.hpp>
19+
#include <boost/rts/polystore.hpp>
2020
#include <boost/rts/zlib.hpp>
2121

2222
#include "test_helpers.hpp"
@@ -55,7 +55,7 @@ struct zlib_test
5555
static
5656
std::string
5757
compress(
58-
const rts::context& ctx,
58+
const rts::polystore& ctx,
5959
core::string_view encoding,
6060
core::string_view body)
6161
{
@@ -65,7 +65,7 @@ struct zlib_test
6565
if(encoding == "deflate" || encoding == "gzip")
6666
{
6767
namespace zlib = rts::zlib;
68-
auto& svc = ctx.get_service<zlib::deflate_service>();
68+
auto& svc = ctx.get<zlib::deflate_service>();
6969
zlib::stream zs{};
7070

7171
auto ret = static_cast<zlib::error>(
@@ -101,7 +101,7 @@ struct zlib_test
101101
else if(encoding == "br")
102102
{
103103
namespace brotli = rts::brotli;
104-
auto& svc = ctx.get_service<brotli::encode_service>();
104+
auto& svc = ctx.get<brotli::encode_service>();
105105

106106
brotli::encoder_state* state =
107107
svc.create_instance(nullptr, nullptr, nullptr);
@@ -145,15 +145,15 @@ struct zlib_test
145145
static
146146
void
147147
verify_compressed(
148-
const rts::context& ctx,
148+
const rts::polystore& ctx,
149149
core::string_view encoding,
150150
core::string_view compressed_body,
151151
core::string_view body)
152152
{
153153
if(encoding == "deflate" || encoding == "gzip")
154154
{
155155
namespace zlib = rts::zlib;
156-
auto& svc = ctx.get_service<zlib::inflate_service>();
156+
auto& svc = ctx.get<zlib::inflate_service>();
157157
zlib::stream zs{};
158158

159159
auto ret = static_cast<zlib::error>(
@@ -192,7 +192,7 @@ struct zlib_test
192192
else if(encoding == "br")
193193
{
194194
namespace brotli = rts::brotli;
195-
auto& svc = ctx.get_service<brotli::decode_service>();
195+
auto& svc = ctx.get<brotli::decode_service>();
196196

197197
brotli::decoder_state* state =
198198
svc.create_instance(nullptr, nullptr, nullptr);
@@ -376,7 +376,7 @@ struct zlib_test
376376
void
377377
test_serializer()
378378
{
379-
rts::context ctx;
379+
rts::polystore ctx;
380380
std::vector<std::string> encodings;
381381
serializer::config cfg;
382382

@@ -612,7 +612,7 @@ struct zlib_test
612612
void
613613
test_parser()
614614
{
615-
rts::context ctx;
615+
rts::polystore ctx;
616616
std::vector<std::string> encodings;
617617
response_parser::config cfg;
618618

0 commit comments

Comments
 (0)