Commit c1c603c1 authored by Dominik Charousset's avatar Dominik Charousset

Fix formatting

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