Commit 77095e22 authored by Jakob Otto's avatar Jakob Otto

Add requested changes

parent c850ba6f
......@@ -120,7 +120,7 @@ void multiplexer::update(const socket_manager_ptr& mgr) {
std::lock_guard<std::mutex> guard{write_lock_};
if (write_handle_ != invalid_socket)
res = write(write_handle_,
as_bytes(make_span(&value, sizeof(intptr_t))));
as_bytes(make_span(&value, 1)));
else
res = sec::socket_invalid;
}
......
......@@ -83,9 +83,8 @@ public:
template <class Manager>
error init(Manager& manager) {
write_buf_.insert(write_buf_.end(),
reinterpret_cast<const byte*>(hello_test.begin()),
reinterpret_cast<const byte*>(hello_test.end()));
auto test_bytes = as_bytes(make_span(hello_test));
write_buf_.insert(write_buf_.end(), test_bytes.begin(), test_bytes.end());
CAF_CHECK(manager.mask_add(operation::read_write));
return none;
}
......@@ -167,8 +166,7 @@ CAF_TEST(send and receive) {
mpx->handle_updates();
CAF_CHECK_EQUAL(mpx->num_socket_managers(), 2u);
CAF_CHECK_EQUAL(write(sockets.second,
as_bytes(make_span(hello_manager.data(),
hello_manager.size()))),
as_bytes(make_span(hello_manager))),
hello_manager.size());
run();
CAF_CHECK_EQUAL(string_view(reinterpret_cast<char*>(buf->data()),
......
......@@ -87,13 +87,12 @@ public:
}
void send(string_view x) {
wr_buf_.insert(wr_buf_.end(), reinterpret_cast<const byte*>(x.begin()),
reinterpret_cast<const byte*>(x.end()));
auto x_bytes = as_bytes(make_span(x));
wr_buf_.insert(wr_buf_.end(), x_bytes.begin(), x_bytes.end());
}
std::string receive() {
std::string result(reinterpret_cast<char*>(rd_buf_.data()),
reinterpret_cast<char*>(read_position_begin()));
std::string result(reinterpret_cast<char*>(rd_buf_.data()), rd_buf_pos_);
rd_buf_pos_ = 0;
return result;
}
......
......@@ -140,8 +140,7 @@ CAF_TEST(receive) {
CAF_CHECK_EQUAL(mpx->num_socket_managers(), 2u);
CAF_MESSAGE("sending data to scribe_policy");
CAF_CHECK_EQUAL(write(sockets.second,
as_bytes(make_span(hello_manager.data(),
hello_manager.size()))),
as_bytes(make_span(hello_manager))),
hello_manager.size());
run();
CAF_CHECK_EQUAL(string_view(reinterpret_cast<char*>(buf->data()),
......
......@@ -93,8 +93,8 @@ public:
if (!msg.match_elements<std::string>())
CAF_FAIL("unexpected message: " << msg);
auto& str = msg.get_as<std::string>(0);
auto byte_ptr = reinterpret_cast<const byte*>(str.data());
buf_->insert(buf_->end(), byte_ptr, byte_ptr + str.size());
auto bytes = as_bytes(make_span(str));
buf_->insert(buf_->end(), bytes.begin(), bytes.end());
}
template <class Parent>
......
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