Commit 9b46d1de authored by Jakob Otto's avatar Jakob Otto

Resolve conflicts with master

parents 742e95b0 18fdd027
......@@ -122,11 +122,14 @@ private:
std::shared_ptr<std::vector<byte>> buf_;
};
class stream_string_application : public string_application {
template <class Base, class Subtype>
class stream_string_application : public Base {
public:
using header_type = typename Base::header_type;
stream_string_application(actor_system& sys,
std::shared_ptr<std::vector<byte>> buf)
: string_application(sys, std::move(buf)), await_payload_(false) {
: Base(sys, std::move(buf)), await_payload_(false) {
// nop
}
......@@ -134,20 +137,20 @@ public:
error init(Parent& parent) {
parent.transport().configure_read(
net::receive_policy::exactly(sizeof(header_type)));
return string_application::init(parent);
return Base::init(parent);
}
template <class Parent>
void handle_data(Parent& parent, span<const byte> data) {
if (await_payload_) {
handle_packet(parent, header_, data);
Base::handle_packet(parent, header_, data);
await_payload_ = false;
} else {
if (data.size() != sizeof(header_type))
CAF_FAIL("");
memcpy(&header_, data.data(), sizeof(header_type));
if (header_.payload == 0)
handle_packet(parent, header_, span<const byte>{});
Base::handle_packet(parent, header_, span<const byte>{});
else
parent.configure_read(net::receive_policy::exactly(header_.payload));
await_payload_ = true;
......@@ -186,6 +189,8 @@ private:
CAF_TEST_FIXTURE_SCOPE(endpoint_manager_tests, fixture)
CAF_TEST(receive) {
using application_type = extend<string_application>::with<
stream_string_application>;
std::vector<byte> read_buf(1024);
CAF_CHECK_EQUAL(mpx->num_socket_managers(), 1u);
auto buf = std::make_shared<std::vector<byte>>();
......@@ -195,12 +200,12 @@ CAF_TEST(receive) {
sec::unavailable_or_would_block);
CAF_MESSAGE("adding both endpoint managers");
auto mgr1 = make_endpoint_manager(mpx, sys, policy::scribe{sockets.first},
stream_string_application{sys, buf});
application_type{sys, buf});
CAF_CHECK_EQUAL(mgr1->init(), none);
mpx->handle_updates();
CAF_CHECK_EQUAL(mpx->num_socket_managers(), 2u);
auto mgr2 = make_endpoint_manager(mpx, sys, policy::scribe{sockets.second},
stream_string_application{sys, buf});
application_type{sys, buf});
CAF_CHECK_EQUAL(mgr2->init(), none);
mpx->handle_updates();
CAF_CHECK_EQUAL(mpx->num_socket_managers(), 3u);
......
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