Commit c1c603c1 authored by Dominik Charousset's avatar Dominik Charousset

Fix formatting

parent 48e941b1
...@@ -55,14 +55,14 @@ public: ...@@ -55,14 +55,14 @@ public:
binary_deserializer(execution_unit* ctx, const void* buf, binary_deserializer(execution_unit* ctx, const void* buf,
size_t size) noexcept size_t size) noexcept
: binary_deserializer(ctx, make_span(reinterpret_cast<const byte*>(buf), : binary_deserializer(ctx,
size)) { make_span(reinterpret_cast<const byte*>(buf), size)) {
// nop // nop
} }
binary_deserializer(actor_system& sys, const void* buf, size_t size) noexcept binary_deserializer(actor_system& sys, const void* buf, size_t size) noexcept
: binary_deserializer(sys, make_span(reinterpret_cast<const byte*>(buf), : binary_deserializer(sys,
size)) { make_span(reinterpret_cast<const byte*>(buf), size)) {
// nop // nop
} }
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
#include "caf/meta/load_callback.hpp" #include "caf/meta/load_callback.hpp"
namespace caf { namespace caf::detail {
namespace detail {
// -- inject `inspect` overloads for some STL types ---------------------------- // -- inject `inspect` overloads for some STL types ----------------------------
...@@ -60,8 +59,8 @@ private: ...@@ -60,8 +59,8 @@ private:
static std::false_type sfinae(Inspector&, ...); static std::false_type sfinae(Inspector&, ...);
using result_type = decltype(sfinae(std::declval<Inspector&>(), using result_type
std::declval<T&>())); = decltype(sfinae(std::declval<Inspector&>(), std::declval<T&>()));
public: public:
static constexpr bool value static constexpr bool value
...@@ -72,5 +71,4 @@ public: ...@@ -72,5 +71,4 @@ public:
template <class Inspector, class T> template <class Inspector, class T>
struct is_inspectable<Inspector, T*> : std::false_type {}; struct is_inspectable<Inspector, T*> : std::false_type {};
} // namespace detail } // namespace caf::detail
} // namespace caf
...@@ -26,32 +26,28 @@ ...@@ -26,32 +26,28 @@
namespace caf::detail { namespace caf::detail {
/// Compile-time list of integer types types. /// Compile-time list of integer types types.
using int_types_by_size = using int_types_by_size = detail::type_list< // bytes
detail::type_list< // bytes void, // 0
void, // 0 detail::type_pair<int8_t, uint8_t>, // 1
detail::type_pair<int8_t, uint8_t>, // 1 detail::type_pair<int16_t, uint16_t>, // 2
detail::type_pair<int16_t, uint16_t>, // 2 void, // 3
void, // 3 detail::type_pair<int32_t, uint32_t>, // 4
detail::type_pair<int32_t, uint32_t>, // 4 void, // 5
void, // 5 void, // 6
void, // 6 void, // 7
void, // 7 detail::type_pair<int64_t, uint64_t> // 8
detail::type_pair<int64_t, uint64_t> // 8
>; >;
/// Squashes integer types into [u]int_[8|16|32|64]_t equivalents /// Squashes integer types into [u]int_[8|16|32|64]_t equivalents
template <class T> template <class T>
struct squashed_int { struct squashed_int {
using tpair = typename detail::tl_at<int_types_by_size, sizeof(T)>::type; using tpair = typename detail::tl_at<int_types_by_size, sizeof(T)>::type;
using type = using type = std::conditional_t<std::is_signed<T>::value, //
typename std::conditional< typename tpair::first, //
std::is_signed<T>::value, typename tpair::second>;
typename tpair::first,
typename tpair::second
>::type;
}; };
template <class T> template <class T>
using squashed_int_t = typename squashed_int<T>::type; using squashed_int_t = typename squashed_int<T>::type;
} // namespace caf } // namespace caf::detail
...@@ -106,8 +106,8 @@ message make_message(T&& x, Ts&&... xs) { ...@@ -106,8 +106,8 @@ message make_message(T&& x, Ts&&... xs) {
"individual types by specializing caf::allowed_unsafe_message_type<T> " "individual types by specializing caf::allowed_unsafe_message_type<T> "
"or by using the macro CAF_ALLOW_UNSAFE_MESSAGE_TYPE"); "or by using the macro CAF_ALLOW_UNSAFE_MESSAGE_TYPE");
using storage = typename tl_apply<stored_types, tuple_vals>::type; using storage = typename tl_apply<stored_types, tuple_vals>::type;
auto ptr = make_counted<storage>(std::forward<T>(x), auto ptr
std::forward<Ts>(xs)...); = make_counted<storage>(std::forward<T>(x), std::forward<Ts>(xs)...);
return message{detail::message_data::cow_ptr{std::move(ptr)}}; return message{detail::message_data::cow_ptr{std::move(ptr)}};
} }
} }
......
...@@ -112,8 +112,8 @@ public: ...@@ -112,8 +112,8 @@ public:
private: private:
template <class Tuple, size_t... Is> template <class Tuple, size_t... Is>
static auto apply_tuple(Subtype& dref, const Tuple& xs, static auto
std::index_sequence<Is...>) { apply_tuple(Subtype& dref, const Tuple& xs, std::index_sequence<Is...>) {
return dref(std::get<Is>(xs)...); return dref(std::get<Is>(xs)...);
} }
......
...@@ -36,52 +36,51 @@ namespace caf { ...@@ -36,52 +36,51 @@ namespace caf {
/// Compile-time list of all built-in types. /// Compile-time list of all built-in types.
/// @warning Types are sorted by uniform name. /// @warning Types are sorted by uniform name.
using sorted_builtin_types = using sorted_builtin_types = detail::type_list< // uniform name:
detail::type_list< actor, // @actor
actor, // @actor std::vector<actor>, // @actorvec
std::vector<actor>, // @actorvec actor_addr, // @addr
actor_addr, // @addr std::vector<actor_addr>, // @addrvec
std::vector<actor_addr>, // @addrvec atom_value, // @atom
atom_value, // @atom std::vector<byte>, // @bytebuf
std::vector<byte>, // @bytebuf std::vector<char>, // @charbuf
std::vector<char>, // @charbuf config_value, // @config_value
config_value, // @config_value down_msg, // @down
down_msg, // @down downstream_msg, // @downstream_msg
downstream_msg, // @downstream_msg duration, // @duration
duration, // @duration error, // @error
error, // @error exit_msg, // @exit
exit_msg, // @exit group, // @group
group, // @group group_down_msg, // @group_down
group_down_msg, // @group_down int16_t, // @i16
int16_t, // @i16 int32_t, // @i32
int32_t, // @i32 int64_t, // @i64
int64_t, // @i64 int8_t, // @i8
int8_t, // @i8 long double, // @ldouble
long double, // @ldouble message, // @message
message, // @message message_id, // @message_id
message_id, // @message_id node_id, // @node
node_id, // @node open_stream_msg, // @open_stream_msg
open_stream_msg, // @open_stream_msg std::string, // @str
std::string, // @str std::map<std::string, std::string>, // @strmap
std::map<std::string, std::string>, // @strmap strong_actor_ptr, // @strong_actor_ptr
strong_actor_ptr, // @strong_actor_ptr std::set<std::string>, // @strset
std::set<std::string>, // @strset std::vector<std::string>, // @strvec
std::vector<std::string>, // @strvec timeout_msg, // @timeout
timeout_msg, // @timeout timespan, // @timespan
timespan, // @timespan timestamp, // @timestamp
timestamp, // @timestamp uint16_t, // @u16
uint16_t, // @u16 std::u16string, // @u16_str
std::u16string, // @u16_str uint32_t, // @u32
uint32_t, // @u32 std::u32string, // @u32_str
std::u32string, // @u32_str uint64_t, // @u64
uint64_t, // @u64 uint8_t, // @u8
uint8_t, // @u8 unit_t, // @unit
unit_t, // @unit upstream_msg, // @upstream_msg
upstream_msg, // @upstream_msg weak_actor_ptr, // @weak_actor_ptr
weak_actor_ptr, // @weak_actor_ptr bool, // bool
bool, // bool double, // double
double, // double float // float
float // float
>; >;
/// Computes the type number for `T`. /// Computes the type number for `T`.
......
...@@ -113,8 +113,8 @@ public: ...@@ -113,8 +113,8 @@ public:
private: private:
template <class Tuple, size_t... Is> template <class Tuple, size_t... Is>
static auto apply_tuple(Subtype& dref, Tuple& xs, static auto
std::index_sequence<Is...>) { apply_tuple(Subtype& dref, Tuple& xs, std::index_sequence<Is...>) {
return dref(std::get<Is>(xs)...); return dref(std::get<Is>(xs)...);
} }
......
...@@ -146,8 +146,7 @@ load_vals(Deserializer& source, message::data_ptr& vals) { ...@@ -146,8 +146,7 @@ load_vals(Deserializer& source, message::data_ptr& vals) {
auto n = next(i); auto n = next(i);
tmp.assign(i, n); tmp.assign(i, n);
auto ptr = types.make_value(tmp); auto ptr = types.make_value(tmp);
if (!ptr) if (!ptr) {
{
CAF_LOG_ERROR("unknown type:" << tmp); CAF_LOG_ERROR("unknown type:" << tmp);
return sec::unknown_type; return sec::unknown_type;
} }
......
...@@ -97,7 +97,7 @@ const char* numbered_type_names[] = { ...@@ -97,7 +97,7 @@ const char* numbered_type_names[] = {
"@weak_actor_ptr", "@weak_actor_ptr",
"bool", "bool",
"double", "double",
"float" "float",
}; };
namespace { namespace {
......
...@@ -157,8 +157,7 @@ CAF_TEST(concatenation) { ...@@ -157,8 +157,7 @@ CAF_TEST(concatenation) {
using i16i8_pair = std::pair<int16_t, int8_t>; using i16i8_pair = std::pair<int16_t, int8_t>;
CHECK_LOAD(i8i16_pair, std::make_pair(int8_t{7}, int16_t{-32683}), // CHECK_LOAD(i8i16_pair, std::make_pair(int8_t{7}, int16_t{-32683}), //
7_b, 0x80_b, 0x55_b); 7_b, 0x80_b, 0x55_b);
CHECK_LOAD(i16i8_pair, CHECK_LOAD(i16i8_pair, std::make_pair(int16_t{-32683}, int8_t{7}), //
std::make_pair(int16_t{-32683}, int8_t{7}), //
0x80_b, 0x55_b, 7_b); 0x80_b, 0x55_b, 7_b);
} }
SUBTEST("calling f(make_tuple(a, b)) is equivalent to f(make_pair(a, b))") { SUBTEST("calling f(make_tuple(a, b)) is equivalent to f(make_pair(a, b))") {
...@@ -166,8 +165,7 @@ CAF_TEST(concatenation) { ...@@ -166,8 +165,7 @@ CAF_TEST(concatenation) {
using i16i8_tuple = std::tuple<int16_t, int8_t>; using i16i8_tuple = std::tuple<int16_t, int8_t>;
CHECK_LOAD(i8i16_tuple, std::make_tuple(int8_t{7}, int16_t{-32683}), // CHECK_LOAD(i8i16_tuple, std::make_tuple(int8_t{7}, int16_t{-32683}), //
7_b, 0x80_b, 0x55_b); 7_b, 0x80_b, 0x55_b);
CHECK_LOAD(i16i8_tuple, CHECK_LOAD(i16i8_tuple, std::make_tuple(int16_t{-32683}, int8_t{7}), //
std::make_tuple(int16_t{-32683}, int8_t{7}), //
0x80_b, 0x55_b, 7_b); 0x80_b, 0x55_b, 7_b);
} }
SUBTEST("arrays behave like tuples") { SUBTEST("arrays behave like tuples") {
...@@ -210,13 +208,13 @@ CAF_TEST(binary serializer picks up inspect functions) { ...@@ -210,13 +208,13 @@ CAF_TEST(binary serializer picks up inspect functions) {
10_b, 11_b, 12_b, 13_b, 14_b, 15_b, 16_b, 17_b, 18_b, 19_b); 10_b, 11_b, 12_b, 13_b, 14_b, 15_b, 16_b, 17_b, 18_b, 19_b);
} }
SUBTEST("custom struct") { SUBTEST("custom struct") {
test_data value{-345, test_data value{
-345,
-1234567890123456789ll, -1234567890123456789ll,
3.45, 3.45,
54.3, 54.3,
caf::duration(caf::time_unit::seconds, 123), caf::duration(caf::time_unit::seconds, 123),
caf::timestamp{ caf::timestamp{caf::timestamp::duration{1478715821 * 1000000000ll}},
caf::timestamp::duration{1478715821 * 1000000000ll}},
test_enum::b, test_enum::b,
"Lorem ipsum dolor sit amet."}; "Lorem ipsum dolor sit amet."};
CHECK_LOAD(test_data, value, CHECK_LOAD(test_data, value,
......
...@@ -153,8 +153,7 @@ CAF_TEST(concatenation) { ...@@ -153,8 +153,7 @@ CAF_TEST(concatenation) {
using i16i8_pair = std::pair<int16_t, int8_t>; using i16i8_pair = std::pair<int16_t, int8_t>;
CHECK_SAVE(i8i16_pair, std::make_pair(int8_t{7}, int16_t{-32683}), // CHECK_SAVE(i8i16_pair, std::make_pair(int8_t{7}, int16_t{-32683}), //
7_b, 0x80_b, 0x55_b); 7_b, 0x80_b, 0x55_b);
CHECK_SAVE(i16i8_pair, CHECK_SAVE(i16i8_pair, std::make_pair(int16_t{-32683}, int8_t{7}), //
std::make_pair(int16_t{-32683}, int8_t{7}), //
0x80_b, 0x55_b, 7_b); 0x80_b, 0x55_b, 7_b);
} }
SUBTEST("calling f(make_tuple(a, b)) is equivalent to f(make_pair(a, b))") { SUBTEST("calling f(make_tuple(a, b)) is equivalent to f(make_pair(a, b))") {
...@@ -162,8 +161,7 @@ CAF_TEST(concatenation) { ...@@ -162,8 +161,7 @@ CAF_TEST(concatenation) {
using i16i8_tuple = std::tuple<int16_t, int8_t>; using i16i8_tuple = std::tuple<int16_t, int8_t>;
CHECK_SAVE(i8i16_tuple, std::make_tuple(int8_t{7}, int16_t{-32683}), // CHECK_SAVE(i8i16_tuple, std::make_tuple(int8_t{7}, int16_t{-32683}), //
7_b, 0x80_b, 0x55_b); 7_b, 0x80_b, 0x55_b);
CHECK_SAVE(i16i8_tuple, CHECK_SAVE(i16i8_tuple, std::make_tuple(int16_t{-32683}, int8_t{7}), //
std::make_tuple(int16_t{-32683}, int8_t{7}), //
0x80_b, 0x55_b, 7_b); 0x80_b, 0x55_b, 7_b);
} }
SUBTEST("arrays behave like tuples") { SUBTEST("arrays behave like tuples") {
......
...@@ -54,9 +54,7 @@ CAF_TEST(shutdown_with_delayed_send) { ...@@ -54,9 +54,7 @@ CAF_TEST(shutdown_with_delayed_send) {
auto f = [](event_based_actor* self) -> behavior { auto f = [](event_based_actor* self) -> behavior {
self->delayed_send(self, std::chrono::nanoseconds(1), ok_atom::value); self->delayed_send(self, std::chrono::nanoseconds(1), ok_atom::value);
return { return {
[=](ok_atom) { [=](ok_atom) { self->quit(); },
self->quit();
}
}; };
}; };
sys.spawn<detached>(f); sys.spawn<detached>(f);
...@@ -76,9 +74,7 @@ CAF_TEST(shutdown_with_after) { ...@@ -76,9 +74,7 @@ CAF_TEST(shutdown_with_after) {
"after()?"); "after()?");
auto f = [](event_based_actor* self) -> behavior { auto f = [](event_based_actor* self) -> behavior {
return { return {
after(std::chrono::nanoseconds(1)) >> [=] { after(std::chrono::nanoseconds(1)) >> [=] { self->quit(); },
self->quit();
}
}; };
}; };
sys.spawn<detached>(f); sys.spawn<detached>(f);
...@@ -92,13 +88,12 @@ CAF_TEST(shutdown_delayed_send_loop) { ...@@ -92,13 +88,12 @@ CAF_TEST(shutdown_delayed_send_loop) {
return { return {
[=](ok_atom) { [=](ok_atom) {
self->delayed_send(self, std::chrono::milliseconds(1), ok_atom::value); self->delayed_send(self, std::chrono::milliseconds(1), ok_atom::value);
} },
}; };
}; };
auto a = sys.spawn<detached>(f); auto a = sys.spawn<detached>(f);
auto g = detail::make_scope_guard([&] { auto g = detail::make_scope_guard(
self->send_exit(a, exit_reason::user_shutdown); [&] { self->send_exit(a, exit_reason::user_shutdown); });
});
} }
CAF_TEST_FIXTURE_SCOPE_END() CAF_TEST_FIXTURE_SCOPE_END()
...@@ -149,12 +149,9 @@ struct fixture : test_coordinator_fixture<config> { ...@@ -149,12 +149,9 @@ struct fixture : test_coordinator_fixture<config> {
test_enum te = test_enum::b; test_enum te = test_enum::b;
string str = "Lorem ipsum dolor sit amet."; string str = "Lorem ipsum dolor sit amet.";
raw_struct rs; raw_struct rs;
test_array ta { test_array ta{
{0, 1, 2, 3}, {0, 1, 2, 3},
{ {{0, 1, 2, 3}, {4, 5, 6, 7}},
{0, 1, 2, 3},
{4, 5, 6, 7}
},
}; };
int ra[3] = {1, 2, 3}; int ra[3] = {1, 2, 3};
...@@ -223,17 +220,13 @@ struct is_message { ...@@ -223,17 +220,13 @@ struct is_message {
bool ok = false; bool ok = false;
// work around for gcc 4.8.4 bug // work around for gcc 4.8.4 bug
auto tup = tie(v, vs...); auto tup = tie(v, vs...);
message_handler impl { message_handler impl{
[&](T const& u, Ts const&... us) { [&](T const& u, Ts const&... us) { ok = tup == tie(u, us...); }};
ok = tup == tie(u, us...);
}
};
impl(msg); impl(msg);
return ok; return ok;
} }
}; };
} // namespace } // namespace
#define CHECK_RT(val) CAF_CHECK_EQUAL(val, roundtrip(val)) #define CHECK_RT(val) CAF_CHECK_EQUAL(val, roundtrip(val))
...@@ -352,7 +345,6 @@ CAF_TEST(multiple_messages) { ...@@ -352,7 +345,6 @@ CAF_TEST(multiple_messages) {
CAF_CHECK(is_message(m2).equal(i32, i64, dur, ts, te, str, rs)); CAF_CHECK(is_message(m2).equal(i32, i64, dur, ts, te, str, rs));
} }
CAF_TEST(type_erased_value) { CAF_TEST(type_erased_value) {
auto buf = serialize(str); auto buf = serialize(str);
type_erased_value_ptr ptr{new type_erased_value_impl<std::string>}; type_erased_value_ptr ptr{new type_erased_value_impl<std::string>};
......
...@@ -55,7 +55,8 @@ public: ...@@ -55,7 +55,8 @@ public:
/// Called if a server handshake was received and /// Called if a server handshake was received and
/// the connection to `nid` is established. /// the connection to `nid` is established.
virtual void finalize_handshake(const node_id& nid, actor_id aid, virtual void finalize_handshake(const node_id& nid, actor_id aid,
std::set<std::string>& sigs) = 0; std::set<std::string>& sigs)
= 0;
/// Called whenever a direct connection was closed or a /// Called whenever a direct connection was closed or a
/// node became unrechable for other reasons *before* /// node became unrechable for other reasons *before*
...@@ -70,8 +71,9 @@ public: ...@@ -70,8 +71,9 @@ public:
/// Called whenever BASP learns the ID of a remote node /// Called whenever BASP learns the ID of a remote node
/// to which it does not have a direct connection. /// to which it does not have a direct connection.
virtual void learned_new_node_directly(const node_id& nid, virtual void
bool was_known_indirectly) = 0; learned_new_node_directly(const node_id& nid, bool was_known_indirectly)
= 0;
/// Called whenever BASP learns the ID of a remote node /// Called whenever BASP learns the ID of a remote node
/// to which it does not have a direct connection. /// to which it does not have a direct connection.
...@@ -113,8 +115,8 @@ public: ...@@ -113,8 +115,8 @@ public:
/// Handles received data and returns a config for receiving the /// Handles received data and returns a config for receiving the
/// next data or `none` if an error occured. /// next data or `none` if an error occured.
connection_state handle(execution_unit* ctx, connection_state
new_data_msg& dm, header& hdr, bool is_payload); handle(execution_unit* ctx, new_data_msg& dm, header& hdr, bool is_payload);
/// Sends heartbeat messages to all valid nodes those are directly connected. /// Sends heartbeat messages to all valid nodes those are directly connected.
void handle_heartbeat(execution_unit* ctx); void handle_heartbeat(execution_unit* ctx);
...@@ -127,17 +129,16 @@ public: ...@@ -127,17 +129,16 @@ public:
/// Sends a BASP message and implicitly flushes the output buffer of `r`. /// Sends a BASP message and implicitly flushes the output buffer of `r`.
/// This function will update `hdr.payload_len` if a payload was written. /// This function will update `hdr.payload_len` if a payload was written.
void write(execution_unit* ctx, const routing_table::route& r, void write(execution_unit* ctx, const routing_table::route& r, header& hdr,
header& hdr, payload_writer* writer = nullptr); payload_writer* writer = nullptr);
/// Adds a new actor to the map of published actors. /// Adds a new actor to the map of published actors.
void add_published_actor(uint16_t port, void add_published_actor(uint16_t port, strong_actor_ptr published_actor,
strong_actor_ptr published_actor,
std::set<std::string> published_interface); std::set<std::string> published_interface);
/// Removes the actor currently assigned to `port`. /// Removes the actor currently assigned to `port`.
size_t remove_published_actor(uint16_t port, size_t
removed_published_actor* cb = nullptr); remove_published_actor(uint16_t port, removed_published_actor* cb = nullptr);
/// Removes `whom` if it is still assigned to `port` or from all of its /// Removes `whom` if it is still assigned to `port` or from all of its
/// current ports if `port == 0`. /// current ports if `port == 0`.
...@@ -181,8 +182,8 @@ public: ...@@ -181,8 +182,8 @@ public:
/// actor published at `port` to `buf`. If `port == none` or /// actor published at `port` to `buf`. If `port == none` or
/// if no actor is published at this port then a standard handshake is /// if no actor is published at this port then a standard handshake is
/// written (e.g. used when establishing direct connections on-the-fly). /// written (e.g. used when establishing direct connections on-the-fly).
void write_server_handshake(execution_unit* ctx, void write_server_handshake(execution_unit* ctx, byte_buffer& out_buf,
byte_buffer& out_buf, optional<uint16_t> port); optional<uint16_t> port);
/// Writes the client handshake to `buf`. /// Writes the client handshake to `buf`.
void write_client_handshake(execution_unit* ctx, byte_buffer& buf); void write_client_handshake(execution_unit* ctx, byte_buffer& buf);
...@@ -192,9 +193,9 @@ public: ...@@ -192,9 +193,9 @@ public:
const node_id& dest_node, actor_id aid); const node_id& dest_node, actor_id aid);
/// Writes a `kill_proxy` to `buf`. /// Writes a `kill_proxy` to `buf`.
void write_down_message(execution_unit* ctx, byte_buffer& buf, void
const node_id& dest_node, actor_id aid, write_down_message(execution_unit* ctx, byte_buffer& buf,
const error& rsn); const node_id& dest_node, actor_id aid, const error& rsn);
/// Writes a `heartbeat` to `buf`. /// Writes a `heartbeat` to `buf`.
void write_heartbeat(execution_unit* ctx, byte_buffer& buf); void write_heartbeat(execution_unit* ctx, byte_buffer& buf);
...@@ -236,4 +237,4 @@ private: ...@@ -236,4 +237,4 @@ private:
/// @} /// @}
} // namespace caf } // namespace caf::io::basp
...@@ -32,12 +32,14 @@ public: ...@@ -32,12 +32,14 @@ public:
/// Called by the underlying I/O device whenever it received data. /// Called by the underlying I/O device whenever it received data.
/// @returns `true` if the manager accepts further reads, otherwise `false`. /// @returns `true` if the manager accepts further reads, otherwise `false`.
virtual bool consume(execution_unit*, datagram_handle hdl, virtual bool
receive_buffer& buf) = 0; consume(execution_unit*, datagram_handle hdl, receive_buffer& buf)
= 0;
/// Called by the underlying I/O device whenever it sent data. /// Called by the underlying I/O device whenever it sent data.
virtual void datagram_sent(execution_unit*, datagram_handle hdl, size_t, virtual void datagram_sent(execution_unit*, datagram_handle hdl, size_t,
byte_buffer buffer) = 0; byte_buffer buffer)
= 0;
/// Called by the underlying I/O device to indicate that a new remote /// Called by the underlying I/O device to indicate that a new remote
/// endpoint has been detected, passing in the received datagram. /// endpoint has been detected, passing in the received datagram.
...@@ -49,5 +51,4 @@ public: ...@@ -49,5 +51,4 @@ public:
virtual uint16_t port(datagram_handle) const = 0; virtual uint16_t port(datagram_handle) const = 0;
}; };
} // namespace caf } // namespace caf::io::network
...@@ -248,8 +248,8 @@ public: ...@@ -248,8 +248,8 @@ public:
/// Appends `buf` to the virtual network buffer of `hdl` /// Appends `buf` to the virtual network buffer of `hdl`
/// and calls `read_data(hdl)` afterwards. /// and calls `read_data(hdl)` afterwards.
void virtual_send(datagram_handle src, datagram_handle ep, void
const byte_buffer&); virtual_send(datagram_handle src, datagram_handle ep, const byte_buffer&);
/// Waits until a `runnable` is available and executes it. /// Waits until a `runnable` is available and executes it.
void exec_runnable(); void exec_runnable();
......
...@@ -71,9 +71,8 @@ void datagram_handler::write(datagram_handle hdl, const void* buf, ...@@ -71,9 +71,8 @@ void datagram_handler::write(datagram_handle hdl, const void* buf,
wr_offline_buf_.emplace_back(); wr_offline_buf_.emplace_back();
wr_offline_buf_.back().first = hdl; wr_offline_buf_.back().first = hdl;
auto cbuf = reinterpret_cast<const byte*>(buf); auto cbuf = reinterpret_cast<const byte*>(buf);
wr_offline_buf_.back().second.assign(cbuf, wr_offline_buf_.back().second.assign(
cbuf cbuf, cbuf + static_cast<ptrdiff_t>(num_bytes));
+ static_cast<ptrdiff_t>(num_bytes));
} }
void datagram_handler::flush(const manager_ptr& mgr) { void datagram_handler::flush(const manager_ptr& mgr) {
...@@ -189,8 +188,8 @@ bool datagram_handler::handle_read_result(bool read_result) { ...@@ -189,8 +188,8 @@ bool datagram_handler::handle_read_result(bool read_result) {
} }
void datagram_handler::handle_write_result(bool write_result, void datagram_handler::handle_write_result(bool write_result,
datagram_handle id, datagram_handle id, byte_buffer& buf,
byte_buffer& buf, size_t wb) { size_t wb) {
if (!write_result) { if (!write_result) {
writer_->io_failure(&backend(), operation::write); writer_->io_failure(&backend(), operation::write);
backend().del(operation::write, fd(), this); backend().del(operation::write, fd(), this);
...@@ -214,4 +213,4 @@ void datagram_handler::handle_error() { ...@@ -214,4 +213,4 @@ void datagram_handler::handle_error() {
// no need to call backend().del() here // no need to call backend().del() here
} }
} // namespace caf } // namespace caf::io::network
...@@ -538,7 +538,7 @@ int main(int argc, char** argv) { ...@@ -538,7 +538,7 @@ int main(int argc, char** argv) {
caf::settings conf; caf::settings conf;
std::vector<std::string> args_cpy{argv + 1, argv + divider}; std::vector<std::string> args_cpy{argv + 1, argv + divider};
auto res = options.parse(conf, args_cpy); auto res = options.parse(conf, args_cpy);
if (res.first!= caf::pec::success) { if (res.first != caf::pec::success) {
std::cerr << "error while parsing argument \"" << *res.second std::cerr << "error while parsing argument \"" << *res.second
<< "\": " << to_string(res.first) << "\n\n"; << "\": " << to_string(res.first) << "\n\n";
std::cerr << options.help_text() << std::endl; std::cerr << options.help_text() << std::endl;
......
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