Commit 1ca0f40e authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'topic/neverlord/clang-format-action'

parents daa75c48 1146591b
name: check-formatting
on: [push, pull_request]
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format.
uses: jidicula/clang-format-action@v4.10.1
with:
clang-format-version: '15'
#include <iostream>
#include <chrono>
#include <iostream>
#include "caf/all.hpp"
#include "caf/io/all.hpp"
using std::cout;
using std::cerr;
using std::cout;
using std::endl;
using namespace caf;
......@@ -38,17 +38,13 @@ behavior connection_worker(broker* self, connection_handle hdl) {
self->write(msg.handle, cstr_size(http_ok), http_ok);
self->quit();
},
[=](const connection_closed_msg&) {
self->quit();
}
[=](const connection_closed_msg&) { self->quit(); },
};
}
behavior server(broker* self) {
auto counter = std::make_shared<int>(0);
self->set_down_handler([=](down_msg&) {
++*counter;
});
self->set_down_handler([=](down_msg&) { ++*counter; });
self->delayed_send(self, std::chrono::seconds(1), tick_atom_v);
return {
[=](const new_connection_msg& ncm) {
......@@ -60,7 +56,7 @@ behavior server(broker* self) {
aout(self) << "Finished " << *counter << " requests per second." << endl;
*counter = 0;
self->delayed_send(self, std::chrono::seconds(1), tick_atom_v);
}
},
};
}
......@@ -69,8 +65,7 @@ public:
uint16_t port = 0;
config() {
opt_group{custom_options_, "global"}
.add(port, "port,p", "set port");
opt_group{custom_options_, "global"}.add(port, "port,p", "set port");
}
};
......
#include <string>
#include <iostream>
#include <string>
#include "caf/actor_ostream.hpp"
#include "caf/actor_system.hpp"
......
......@@ -28,7 +28,6 @@ using std::endl;
using std::chrono::seconds;
using namespace caf;
/// A simple actor for storing an integer value.
using cell = typed_actor<
// Writes a new value.
......
......@@ -8,9 +8,9 @@
#include "caf/net/binary/frame.hpp"
CAF_PUSH_WARNINGS
#include <QWidget>
#include <QLineEdit>
#include <QTextEdit>
#include <QWidget>
CAF_POP_WARNINGS
CAF_BEGIN_TYPE_ID_BLOCK(qtsupport, first_custom_type_id)
......@@ -48,8 +48,7 @@ public slots:
void changeName();
private:
template<typename T>
template <typename T>
T* get(T*& member, const char* name) {
if (member == nullptr) {
member = findChild<T*>(name);
......
......@@ -70,8 +70,8 @@ public:
/// @cond PRIVATE
static intptr_t
compare(const actor_control_block* lhs, const actor_control_block* rhs);
static intptr_t compare(const actor_control_block* lhs,
const actor_control_block* rhs);
intptr_t compare(const actor_addr& other) const noexcept;
......
......@@ -6,9 +6,9 @@
#include <type_traits>
#include "caf/fwd.hpp"
#include "caf/abstract_actor.hpp"
#include "caf/actor_control_block.hpp"
#include "caf/fwd.hpp"
namespace caf {
......@@ -40,7 +40,7 @@ namespace {
constexpr int raw_ptr_cast = 0; // either To or From is a raw pointer
constexpr int weak_ptr_downgrade_cast = 12; // To is weak, From is strong
constexpr int weak_ptr_upgrade_cast = 3; // To is strong, From is weak
constexpr int weak_ptr_upgrade_cast = 3; // To is strong, From is weak
constexpr int neutral_cast = 6; // To and From are both weak or both strong
template <class T>
......@@ -146,9 +146,7 @@ public:
template <class T, class U>
T actor_cast(U&& what) {
using from_type =
typename std::remove_const<
typename std::remove_reference<U>::type
>::type;
typename std::remove_const<typename std::remove_reference<U>::type>::type;
// query traits for T
constexpr bool to_raw = std::is_pointer<T>::value;
constexpr bool to_weak = is_weak_ptr<T>::value;
......@@ -164,4 +162,3 @@ T actor_cast(U&& what) {
}
} // namespace caf
......@@ -159,13 +159,13 @@ inline bool operator!=(const abstract_actor* x, const strong_actor_ptr& y) {
/// @relates actor_control_block
using weak_actor_ptr = weak_intrusive_ptr<actor_control_block>;
CAF_CORE_EXPORT error_code<sec>
load_actor(strong_actor_ptr& storage, execution_unit*, actor_id aid,
const node_id& nid);
CAF_CORE_EXPORT error_code<sec> load_actor(strong_actor_ptr& storage,
execution_unit*, actor_id aid,
const node_id& nid);
CAF_CORE_EXPORT error_code<sec>
save_actor(strong_actor_ptr& storage, execution_unit*, actor_id aid,
const node_id& nid);
CAF_CORE_EXPORT error_code<sec> save_actor(strong_actor_ptr& storage,
execution_unit*, actor_id aid,
const node_id& nid);
template <class Inspector>
auto context_of(Inspector* f) -> decltype(f->context()) {
......@@ -178,8 +178,8 @@ inline execution_unit* context_of(void*) {
CAF_CORE_EXPORT std::string to_string(const strong_actor_ptr& x);
CAF_CORE_EXPORT void
append_to_string(std::string& x, const strong_actor_ptr& y);
CAF_CORE_EXPORT void append_to_string(std::string& x,
const strong_actor_ptr& y);
CAF_CORE_EXPORT std::string to_string(const weak_actor_ptr& x);
......
......@@ -82,8 +82,8 @@ public:
/// Returns an actor pool with `n` workers created by the factory
/// function `fac` using the dispatch policy `pol`.
static actor
make(execution_unit* eu, size_t num_workers, const factory& fac, policy pol);
static actor make(execution_unit* eu, size_t num_workers, const factory& fac,
policy pol);
bool enqueue(mailbox_element_ptr what, execution_unit* eu) override;
......
......@@ -77,9 +77,9 @@ struct default_actor_traits<T, true> {
/// Denotes whether `T` is an incomplete actor type that misses one or more
/// markers.
static constexpr bool is_incomplete
= (!is_dynamically_typed && !is_statically_typed)
|| (!is_blocking && !is_non_blocking);
static constexpr bool is_incomplete = (!is_dynamically_typed
&& !is_statically_typed)
|| (!is_blocking && !is_non_blocking);
static_assert(!is_dynamically_typed || !is_statically_typed,
"an actor cannot be both statically and dynamically typed");
......
......@@ -28,8 +28,8 @@ public:
const_typed_message_view(const const_typed_message_view&) noexcept = default;
const_typed_message_view&
operator=(const const_typed_message_view&) noexcept = default;
const_typed_message_view& operator=(const const_typed_message_view&) noexcept
= default;
const detail::message_data* operator->() const noexcept {
return ptr_;
......
......@@ -20,4 +20,3 @@ bool operator==(const delegated<Ts...>&, const delegated<Ts...>&) {
}
} // namespace caf
......@@ -90,11 +90,12 @@ public:
// nop
}
constexpr linked_list_iterator(
const linked_list_iterator&) noexcept = default;
constexpr linked_list_iterator(const linked_list_iterator&) noexcept
= default;
constexpr linked_list_iterator&
operator=(const linked_list_iterator&) noexcept = default;
operator=(const linked_list_iterator&) noexcept
= default;
constexpr node_pointer get() const noexcept {
return ptr_;
......
......@@ -20,8 +20,8 @@ void mask_bits(std::array<uint8_t, NumBytes>& bytes, size_t bits_to_keep) {
auto byte_cutoff = bits_to_keep % 8;
auto i = bytes.begin() + bytes_to_keep;
if (byte_cutoff != 0) {
static constexpr uint8_t mask[]
= {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE};
static constexpr uint8_t mask[] = {0x00, 0x80, 0xC0, 0xE0,
0xF0, 0xF8, 0xFC, 0xFE};
*i = *i & mask[byte_cutoff];
++i;
}
......
......@@ -46,18 +46,15 @@
ps.code = ch != '\n' ? caf::pec::unexpected_character \
: caf::pec::unexpected_newline; \
return; \
s_##name : \
if (ch == '\0') \
goto s_unexpected_eof; \
e_##name :
s_##name : if (ch == '\0') goto s_unexpected_eof; \
e_##name:
/// Defines a state in the FSM that doesn't check for end-of-input. Unstable
/// states must make a transition and cause undefined behavior otherwise.
#define unstable_state(name) \
} \
{ \
s_##name : \
e_##name :
s_##name : e_##name:
/// Ends the definition of an FSM.
#define fin() \
......@@ -67,33 +64,29 @@
return;
/// Defines a terminal state in the FSM.
#define CAF_TERM_STATE_IMPL1(name) \
#define CAF_TERM_STATE_IMPL1(name) \
} \
for (;;) { \
/* jumps back up here if no transition matches */ \
ps.code = caf::pec::trailing_character; \
return; \
s_##name : \
if (ch == '\0') \
goto s_fin; \
e_##name :
s_##name : if (ch == '\0') goto s_fin; \
e_##name:
/// Defines a terminal state in the FSM that runs `exit_statement` when leaving
/// the state with code `pec::success` or `pec::trailing_character`.
#define CAF_TERM_STATE_IMPL2(name, exit_statement) \
#define CAF_TERM_STATE_IMPL2(name, exit_statement) \
} \
for (;;) { \
/* jumps back up here if no transition matches */ \
ps.code = caf::pec::trailing_character; \
exit_statement; \
return; \
s_##name : \
if (ch == '\0') { \
s_##name : if (ch == '\0') { \
exit_statement; \
goto s_fin; \
} \
e_##name :
e_##name:
#define CAF_TRANSITION_IMPL1(target) \
ch = ps.next(); \
......@@ -210,65 +203,69 @@
#ifdef CAF_MSVC
/// Defines a terminal state in the FSM.
#define term_state(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_TERM_STATE_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
# define term_state(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_TERM_STATE_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
/// Transitions to target state if a predicate (optional argument 1) holds for
/// the current token and executes an action (optional argument 2) before
/// entering the new state.
#define transition(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
# define transition(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
/// Stops the FSM with reason `error_code` if `predicate` holds for the current
/// token.
#define error_transition(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_ERROR_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__),\
CAF_PP_EMPTY())
# define error_transition(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_ERROR_TRANSITION_IMPL, \
__VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
// Makes an epsilon transition into another state.
#define epsilon(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
# define epsilon(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
/// Makes an transition transition into another FSM, resuming at state `target`.
#define fsm_transition(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_FSM_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__),\
CAF_PP_EMPTY())
# define fsm_transition(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_FSM_TRANSITION_IMPL, \
__VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
/// Makes an epsilon transition into another FSM, resuming at state `target`.
#define fsm_epsilon(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_FSM_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
# define fsm_epsilon(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_FSM_EPSILON_IMPL, \
__VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
#else // CAF_MSVC
/// Defines a terminal state in the FSM.
#define term_state(...) \
CAF_PP_OVERLOAD(CAF_TERM_STATE_IMPL, __VA_ARGS__)(__VA_ARGS__)
# define term_state(...) \
CAF_PP_OVERLOAD(CAF_TERM_STATE_IMPL, __VA_ARGS__)(__VA_ARGS__)
/// Transitions to target state if a predicate (optional argument 1) holds for
/// the current token and executes an action (optional argument 2) before
/// entering the new state.
#define transition(...) \
CAF_PP_OVERLOAD(CAF_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__)
# define transition(...) \
CAF_PP_OVERLOAD(CAF_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__)
/// Stops the FSM with reason `error_code` if `predicate` holds for the current
/// token.
#define error_transition(...) \
CAF_PP_OVERLOAD(CAF_ERROR_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__)
# define error_transition(...) \
CAF_PP_OVERLOAD(CAF_ERROR_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__)
// Makes an epsilon transition into another state.
#define epsilon(...) CAF_PP_OVERLOAD(CAF_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__)
# define epsilon(...) \
CAF_PP_OVERLOAD(CAF_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__)
/// Makes an transition transition into another FSM, resuming at state `target`.
#define fsm_transition(...) \
CAF_PP_OVERLOAD(CAF_FSM_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__)
# define fsm_transition(...) \
CAF_PP_OVERLOAD(CAF_FSM_TRANSITION_IMPL, __VA_ARGS__)(__VA_ARGS__)
/// Makes an epsilon transition into another FSM, resuming at state `target`.
#define fsm_epsilon(...) \
CAF_PP_OVERLOAD(CAF_FSM_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__)
# define fsm_epsilon(...) \
CAF_PP_OVERLOAD(CAF_FSM_EPSILON_IMPL, __VA_ARGS__)(__VA_ARGS__)
#endif // CAF_MSVC
......
......@@ -10,7 +10,7 @@
#define CAF_PP_EMPTY()
/// Concatenates x and y into a single token.
#define CAF_PP_CAT(x, y) x ## y
#define CAF_PP_CAT(x, y) x##y
/// Evaluate x and y before concatenating into a single token.
#define CAF_PP_PASTE(x, y) CAF_PP_CAT(x, y)
......@@ -25,24 +25,24 @@
#ifdef CAF_MSVC
/// Computes the number of arguments of a variadic pack.
#define CAF_PP_SIZE(...) \
CAF_PP_PASTE(CAF_PP_SIZE_I(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, \
55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, \
43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, \
31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, \
6, 5, 4, 3, 2, 1, ), \
CAF_PP_EMPTY())
# define CAF_PP_SIZE(...) \
CAF_PP_PASTE(CAF_PP_SIZE_I(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, \
56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, \
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, \
32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, \
20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, \
8, 7, 6, 5, 4, 3, 2, 1, ), \
CAF_PP_EMPTY())
#else // CAF_MSVC
/// Computes the number of arguments of a variadic pack.
#define CAF_PP_SIZE(...) \
CAF_PP_SIZE_I(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, \
52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, \
37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, \
6, 5, 4, 3, 2, 1, )
# define CAF_PP_SIZE(...) \
CAF_PP_SIZE_I(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, \
52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, \
37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, \
6, 5, 4, 3, 2, 1, )
#endif // CAF_MSVC
......
......@@ -13,8 +13,8 @@ namespace caf::detail {
CAF_CORE_EXPORT void prettify_type_name(std::string& class_name);
CAF_CORE_EXPORT void
prettify_type_name(std::string& class_name, const char* input_class_name);
CAF_CORE_EXPORT void prettify_type_name(std::string& class_name,
const char* input_class_name);
CAF_CORE_EXPORT std::string pretty_type_name(const std::type_info& x);
......
......@@ -48,7 +48,7 @@
namespace caf::detail {
/// Creates a hash from `data` using the RIPEMD-160 algorithm.
CAF_CORE_EXPORT void
ripemd_160(std::array<uint8_t, 20>& storage, const std::string& data);
CAF_CORE_EXPORT void ripemd_160(std::array<uint8_t, 20>& storage,
const std::string& data);
} // namespace caf::detail
......@@ -86,8 +86,8 @@ public:
xs.emplace_back(worker, message{});
ulock.unlock();
using collector_t = split_join_collector<T, Split, Join>;
auto hdl
= sys.spawn<collector_t, lazy_init>(init_, sf_, jf_, std::move(xs));
auto hdl = sys.spawn<collector_t, lazy_init>(init_, sf_, jf_,
std::move(xs));
hdl->enqueue(std::move(ptr), host);
}
......
......@@ -386,9 +386,9 @@ constexpr size_t tl_count<List, Pred>::value;
/// Counts the number of elements in the list which are equal to `T`.
template <class List, class T>
struct tl_count_type {
static constexpr size_t value
= (std::is_same<tl_head_t<List>, T>::value ? 1 : 0)
+ tl_count_type<tl_tail_t<List>, T>::value;
static constexpr size_t value = (std::is_same<tl_head_t<List>, T>::value ? 1
: 0)
+ tl_count_type<tl_tail_t<List>, T>::value;
};
template <class T>
......
......@@ -59,18 +59,16 @@ int exec_main(F fun, int argc, char** argv) {
using trait = typename detail::get_callable_trait<F>::type;
using arg_types = typename trait::arg_types;
static_assert(detail::tl_size<arg_types>::value == 1
|| detail::tl_size<arg_types>::value == 2,
|| detail::tl_size<arg_types>::value == 2,
"main function must have one or two arguments");
static_assert(std::is_same<
typename detail::tl_head<arg_types>::type,
actor_system&
>::value,
static_assert(std::is_same<typename detail::tl_head<arg_types>::type,
actor_system&>::value,
"main function must take actor_system& as first parameter");
using arg2 = typename detail::tl_at<arg_types, 1>::type;
using decayed_arg2 = typename std::decay<arg2>::type;
static_assert(std::is_same<arg2, unit_t>::value
|| (std::is_base_of<actor_system_config, decayed_arg2>::value
&& std::is_same<arg2, const decayed_arg2&>::value),
|| (std::is_base_of<actor_system_config, decayed_arg2>::value
&& std::is_same<arg2, const decayed_arg2&>::value),
"second parameter of main function must take a subtype of "
"actor_system_config as const reference");
using helper = exec_main_helper<typename trait::arg_types>;
......
......@@ -17,7 +17,7 @@ struct extend_helper<D, B> {
};
template <class D, class B, template <class, class> class M,
template <class, class> class... Ms>
template <class, class> class... Ms>
struct extend_helper<D, B, M, Ms...> : extend_helper<D, M<B, D>, Ms...> {
// no content
};
......@@ -40,4 +40,3 @@ struct extend {
};
} // namespace caf
......@@ -607,9 +607,9 @@ auto observable<T>::merge(Inputs&&... xs) {
static_assert(
sizeof...(Inputs) > 0,
"merge without arguments expects this observable to emit observables");
static_assert(
(std::is_same_v<Out, output_type_t<std::decay_t<Inputs>>> && ...),
"can only merge observables with the same observed type");
static_assert((std::is_same_v<Out, output_type_t<std::decay_t<Inputs>>>
&& ...),
"can only merge observables with the same observed type");
using impl_t = op::merge<Out>;
return make_observable<impl_t>(ctx(), *this, std::forward<Inputs>(xs)...);
}
......
......@@ -35,10 +35,10 @@ T* intrusive_cow_ptr_unshare(T*& ptr) {
/// copy-on-write optimization.
template <class T>
class intrusive_cow_ptr
: detail::comparable<intrusive_cow_ptr<T>>,
detail::comparable<intrusive_cow_ptr<T>, T*>,
detail::comparable<intrusive_cow_ptr<T>, std::nullptr_t>,
detail::comparable<intrusive_cow_ptr<T>, intrusive_ptr<T>> {
: detail::comparable<intrusive_cow_ptr<T>>,
detail::comparable<intrusive_cow_ptr<T>, T*>,
detail::comparable<intrusive_cow_ptr<T>, std::nullptr_t>,
detail::comparable<intrusive_cow_ptr<T>, intrusive_ptr<T>> {
public:
// -- member types -----------------------------------------------------------
......@@ -68,7 +68,7 @@ public:
template <class Y>
intrusive_cow_ptr(intrusive_cow_ptr<Y> other) noexcept
: ptr_(other.detach(), false) {
: ptr_(other.detach(), false) {
// nop
}
......@@ -77,7 +77,7 @@ public:
}
explicit intrusive_cow_ptr(pointer ptr, bool add_ref = true) noexcept
: ptr_(ptr, add_ref) {
: ptr_(ptr, add_ref) {
// nop
}
......
......@@ -188,10 +188,9 @@ public:
using super::super;
template <
class U,
class = std::enable_if_t<
std::is_constructible_v<T, U> && !std::is_constructible_v<super, U>>>
template <class U,
class = std::enable_if_t<std::is_constructible_v<T, U>
&& !std::is_constructible_v<super, U>>>
result(U&& x)
: super(detail::result_base_message_init{}, T{std::forward<U>(x)}) {
// nop
......
......@@ -4,7 +4,6 @@
#pragma once
#include "caf/scheduler/worker.hpp"
#include "caf/scheduler/coordinator.hpp"
#include "caf/scheduler/abstract_coordinator.hpp"
#include "caf/scheduler/coordinator.hpp"
#include "caf/scheduler/worker.hpp"
......@@ -99,11 +99,11 @@ public:
m.mem = 0;
#else
::rusage ru;
#ifdef RUSAGE_THREAD
# ifdef RUSAGE_THREAD
::getrusage(RUSAGE_THREAD, &ru);
#else
# else
::getrusage(RUSAGE_SELF, &ru);
#endif
# endif
m.usr = to_usec(ru.ru_utime);
m.sys = to_usec(ru.ru_stime);
m.mem = ru.ru_maxrss;
......@@ -172,8 +172,8 @@ public:
if (!file_)
std::cerr << R"([WARNING] could not open file ")" << fname
<< R"(" (no profiler output will be generated))" << std::endl;
auto res
= get_or(cfg, "scheduler.profiling-resolution", sr::profiling_resolution);
auto res = get_or(cfg, "scheduler.profiling-resolution",
sr::profiling_resolution);
resolution_ = std::chrono::duration_cast<msec>(res);
}
......
......@@ -49,8 +49,9 @@ template <message_priority P = message_priority::normal, class Source,
void unsafe_send_as(Source* src, const Dest& dest, Ts&&... xs) {
static_assert(sizeof...(Ts) > 0, "no message to send");
if (dest)
actor_cast<abstract_actor*>(dest)->eq_impl(
make_message_id(P), src->ctrl(), src->context(), std::forward<Ts>(xs)...);
actor_cast<abstract_actor*>(dest)->eq_impl(make_message_id(P), src->ctrl(),
src->context(),
std::forward<Ts>(xs)...);
}
template <class... Ts>
......
......@@ -16,8 +16,8 @@ namespace detail {
class behavior_impl;
CAF_CORE_EXPORT behavior_impl*
new_default_behavior(timespan d, std::function<void()> fun);
CAF_CORE_EXPORT behavior_impl* new_default_behavior(timespan d,
std::function<void()> fun);
} // namespace detail
......
......@@ -17,12 +17,14 @@ public:
/// Deserializes tracing data from `source` and either overrides the content
/// of `dst` or allocates a new object if `dst` is null.
/// @returns the result of `source`.
virtual bool deserialize(deserializer& source,
std::unique_ptr<tracing_data>& dst) const = 0;
virtual bool
deserialize(deserializer& source, std::unique_ptr<tracing_data>& dst) const
= 0;
/// @copydoc deserialize
virtual bool deserialize(binary_deserializer& source,
std::unique_ptr<tracing_data>& dst) const = 0;
std::unique_ptr<tracing_data>& dst) const
= 0;
};
} // namespace caf
......@@ -333,9 +333,7 @@ public:
[[maybe_unused]] constexpr bool operator!=(atom_name, atom_name) { \
return false; \
} \
inline std::string to_string(atom_name) { \
return atom_text; \
} \
inline std::string to_string(atom_name) { return atom_text; } \
template <class Inspector> \
auto inspect(Inspector& f, atom_name& x) { \
return f.object(x).fields(); \
......
......@@ -42,11 +42,9 @@ struct same_input : std::is_same<Input, typename RepliesToWith::input_types> {};
template <class Output, class RepliesToWith>
struct same_output_or_skip_t {
using other = typename RepliesToWith::output_types;
static constexpr bool value = std::is_same<
Output,
typename RepliesToWith::output_types>::value
|| std::is_same<Output,
type_list<skip_t>>::value;
static constexpr bool value
= std::is_same<Output, typename RepliesToWith::output_types>::value
|| std::is_same<Output, type_list<skip_t>>::value;
};
template <class SList>
......@@ -56,16 +54,17 @@ struct valid_input_predicate {
using input_types = typename Expr::input_types;
using output_types = typename Expr::output_types;
// get matching elements for input type
using filtered_slist = typename tl_filter<
SList, tbind<same_input, input_types>::template type>::type;
using filtered_slist =
typename tl_filter<SList,
tbind<same_input, input_types>::template type>::type;
static_assert(tl_size<filtered_slist>::value > 0,
"cannot assign given match expression to "
"typed behavior, because the expression "
"contains at least one pattern that is "
"not defined in the actor's type");
static constexpr bool value = tl_exists<
filtered_slist,
tbind<same_output_or_skip_t, output_types>::template type>::value;
static constexpr bool value
= tl_exists<filtered_slist, tbind<same_output_or_skip_t,
output_types>::template type>::value;
// check whether given output matches in the filtered list
static_assert(value, "cannot assign given match expression to "
"typed behavior, because at least one return "
......@@ -88,22 +87,20 @@ template <class SList, class IList>
struct valid_input {
// strip exit_msg and down_msg from input types,
// because they're always allowed
using adjusted_slist = typename tl_filter_not<SList,
is_system_msg_handler>::type;
using adjusted_ilist = typename tl_filter_not<IList,
is_system_msg_handler>::type;
using adjusted_slist =
typename tl_filter_not<SList, is_system_msg_handler>::type;
using adjusted_ilist =
typename tl_filter_not<IList, is_system_msg_handler>::type;
// check for each element in IList that there's an element in SList that
// (1) has an identical input type list
// (2) has an identical output type list
// OR the output of the element in IList is skip_t
static_assert(detail::tl_is_distinct<IList>::value,
"given pattern is not distinct");
static constexpr bool value = tl_size<adjusted_slist>::value
== tl_size<adjusted_ilist>::value
&& tl_forall<
adjusted_ilist,
valid_input_predicate<
adjusted_slist>::template inner>::value;
static constexpr bool value
= tl_size<adjusted_slist>::value == tl_size<adjusted_ilist>::value
&& tl_forall<adjusted_ilist, valid_input_predicate<
adjusted_slist>::template inner>::value;
};
// this function is called from typed_behavior<...>::set and its whole
......
......@@ -24,17 +24,14 @@ public:
/// implementation with static type-checking.
/// @extends local_actor
template <class... Sigs>
class typed_event_based_actor : public extend<scheduled_actor,
typed_event_based_actor<Sigs...>
>::template
with<mixin::sender, mixin::requester,
mixin::behavior_changer>,
public statically_typed_actor_base {
class typed_event_based_actor
: public extend<scheduled_actor, typed_event_based_actor<Sigs...>>::
template with<mixin::sender, mixin::requester, mixin::behavior_changer>,
public statically_typed_actor_base {
public:
using super = typename
extend<scheduled_actor,
typed_event_based_actor<Sigs...>>::template
with<mixin::sender, mixin::requester, mixin::behavior_changer>;
using super =
typename extend<scheduled_actor, typed_event_based_actor<Sigs...>>::
template with<mixin::sender, mixin::requester, mixin::behavior_changer>;
explicit typed_event_based_actor(actor_config& cfg) : super(cfg) {
// nop
......@@ -57,7 +54,7 @@ public:
this->setf(abstract_actor::is_initialized_flag);
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG2("alive", this->alive()));
<< CAF_ARG2("alive", this->alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......@@ -78,4 +75,3 @@ protected:
};
} // namespace caf
......@@ -4,23 +4,23 @@
#pragma once
#include <cstddef>
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <type_traits>
#include "caf/intrusive_ptr.hpp"
#include "caf/detail/comparable.hpp"
#include "caf/intrusive_ptr.hpp"
namespace caf {
/// An intrusive, reference counting smart pointer implementation.
/// @relates ref_counted
template <class T>
class weak_intrusive_ptr : detail::comparable<weak_intrusive_ptr<T>>,
detail::comparable<weak_intrusive_ptr<T>, const T*>,
detail::comparable<weak_intrusive_ptr<T>,
std::nullptr_t> {
class weak_intrusive_ptr
: detail::comparable<weak_intrusive_ptr<T>>,
detail::comparable<weak_intrusive_ptr<T>, const T*>,
detail::comparable<weak_intrusive_ptr<T>, std::nullptr_t> {
public:
using pointer = T*;
using const_pointer = const T*;
......@@ -40,7 +40,7 @@ public:
}
weak_intrusive_ptr(weak_intrusive_ptr&& other) noexcept
: ptr_(other.detach()) {
: ptr_(other.detach()) {
// nop
}
......@@ -50,7 +50,7 @@ public:
template <class Y>
weak_intrusive_ptr(weak_intrusive_ptr<Y> other) noexcept
: ptr_(other.detach()) {
: ptr_(other.detach()) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
}
......
......@@ -4,9 +4,9 @@
#include "caf/config.hpp"
#include <atomic>
#include <map>
#include <mutex>
#include <atomic>
#include <stdexcept>
#include "caf/abstract_actor.hpp"
......@@ -46,7 +46,7 @@ bool abstract_actor::enqueue(strong_actor_ptr sender, message_id mid,
}
abstract_actor::abstract_actor(actor_config& cfg)
: abstract_channel(cfg.flags) {
: abstract_channel(cfg.flags) {
// nop
}
......
......@@ -5,11 +5,11 @@
#include "caf/actor_addr.hpp"
#include "caf/actor.hpp"
#include "caf/node_id.hpp"
#include "caf/serializer.hpp"
#include "caf/local_actor.hpp"
#include "caf/deserializer.hpp"
#include "caf/local_actor.hpp"
#include "caf/node_id.hpp"
#include "caf/proxy_registry.hpp"
#include "caf/serializer.hpp"
namespace caf {
......@@ -27,7 +27,7 @@ actor_addr::actor_addr(actor_control_block* ptr) : ptr_(ptr) {
}
actor_addr::actor_addr(actor_control_block* ptr, bool add_ref)
: ptr_(ptr, add_ref) {
: ptr_(ptr, add_ref) {
// nop
}
......
......@@ -4,8 +4,8 @@
#include "caf/actor_registry.hpp"
#include <mutex>
#include <limits>
#include <mutex>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
......@@ -57,9 +57,7 @@ void actor_registry::put_impl(actor_id key, strong_actor_ptr val) {
// attach functor without lock
CAF_LOG_DEBUG("added actor:" << CAF_ARG(key));
actor_registry* reg = this;
val->get()->attach_functor([key, reg]() {
reg->erase(key);
});
val->get()->attach_functor([key, reg]() { reg->erase(key); });
}
void actor_registry::erase(actor_id key) {
......
......@@ -22,7 +22,7 @@ attachable::~attachable() {
}
attachable::token::token(size_t typenr, const void* vptr)
: subtype(typenr), ptr(vptr) {
: subtype(typenr), ptr(vptr) {
// nop
}
......
......@@ -21,12 +21,12 @@ sequencer::sequencer(strong_actor_ptr f, strong_actor_ptr g,
// composed actor has dependency on constituent actors by default;
// if either constituent actor is already dead upon establishing
// the dependency, the actor is spawned dead
auto monitor1
= default_attachable::make_monitor(actor_cast<actor_addr>(f_), address());
auto monitor1 = default_attachable::make_monitor(actor_cast<actor_addr>(f_),
address());
f_->get()->attach(std::move(monitor1));
if (g_ != f_) {
auto monitor2
= default_attachable::make_monitor(actor_cast<actor_addr>(g_), address());
auto monitor2 = default_attachable::make_monitor(actor_cast<actor_addr>(g_),
address());
g_->get()->attach(std::move(monitor2));
}
}
......
......@@ -5,8 +5,8 @@
#include "caf/default_attachable.hpp"
#include "caf/actor.hpp"
#include "caf/message.hpp"
#include "caf/actor_cast.hpp"
#include "caf/message.hpp"
#include "caf/system_messages.hpp"
namespace caf {
......@@ -42,10 +42,10 @@ bool default_attachable::matches(const token& what) {
default_attachable::default_attachable(actor_addr observed, actor_addr observer,
observe_type type,
message_priority priority)
: observed_(std::move(observed)),
observer_(std::move(observer)),
type_(type),
priority_(priority) {
: observed_(std::move(observed)),
observer_(std::move(observer)),
type_(type),
priority_(priority) {
// nop
}
......
......@@ -2,8 +2,8 @@
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/message_id.hpp"
#include "caf/event_based_actor.hpp"
#include "caf/message_id.hpp"
#include "caf/detail/pretty_type_name.hpp"
......@@ -18,13 +18,13 @@ event_based_actor::~event_based_actor() {
}
void event_based_actor::initialize() {
CAF_LOG_TRACE(CAF_ARG2("subtype",
detail::pretty_type_name(typeid(*this)).c_str()));
CAF_LOG_TRACE(
CAF_ARG2("subtype", detail::pretty_type_name(typeid(*this)).c_str()));
extended_base::initialize();
setf(is_initialized_flag);
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG2("alive", alive()));
<< CAF_ARG2("alive", alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......
......@@ -7,8 +7,7 @@
namespace caf {
execution_unit::execution_unit(actor_system* sys)
: system_(sys),
proxies_(nullptr) {
: system_(sys), proxies_(nullptr) {
// nop
}
......
......@@ -15,8 +15,7 @@ ipv4_subnet::ipv4_subnet() : prefix_length_(0) {
}
ipv4_subnet::ipv4_subnet(ipv4_address network_address, uint8_t prefix_length)
: address_(network_address),
prefix_length_(prefix_length) {
: address_(network_address), prefix_length_(prefix_length) {
detail::mask_bits(address_.bytes(), prefix_length_);
}
......@@ -31,8 +30,8 @@ bool ipv4_subnet::contains(ipv4_subnet other) const noexcept {
if (prefix_length_ > other.prefix_length_)
return false;
return prefix_length_ == other.prefix_length_
? address_ == other.address_
: address_ == other.address_.network_address(prefix_length_);
? address_ == other.address_
: address_ == other.address_.network_address(prefix_length_);
}
// -- comparison ---------------------------------------------------------------
......
......@@ -15,20 +15,18 @@ ipv6_subnet::ipv6_subnet() : prefix_length_(0) {
}
ipv6_subnet::ipv6_subnet(ipv4_subnet subnet)
: address_(ipv6_address{subnet.network_address()}),
prefix_length_(v4_offset + subnet.prefix_length()){
: address_(ipv6_address{subnet.network_address()}),
prefix_length_(v4_offset + subnet.prefix_length()) {
detail::mask_bits(address_.bytes(), prefix_length_);
}
ipv6_subnet::ipv6_subnet(ipv4_address network_address, uint8_t prefix_length)
: address_(network_address),
prefix_length_(prefix_length + v4_offset) {
: address_(network_address), prefix_length_(prefix_length + v4_offset) {
detail::mask_bits(address_.bytes(), prefix_length_);
}
ipv6_subnet::ipv6_subnet(ipv6_address network_address, uint8_t prefix_length)
: address_(network_address),
prefix_length_(prefix_length) {
: address_(network_address), prefix_length_(prefix_length) {
detail::mask_bits(address_.bytes(), prefix_length_);
}
......@@ -52,8 +50,8 @@ bool ipv6_subnet::contains(ipv6_subnet other) const noexcept {
if (prefix_length_ > other.prefix_length_)
return false;
return prefix_length_ == other.prefix_length_
? address_ == other.address_
: address_ == other.address_.network_address(prefix_length_);
? address_ == other.address_
: address_ == other.address_.network_address(prefix_length_);
}
bool ipv6_subnet::contains(ipv4_address addr) const noexcept {
......@@ -82,4 +80,3 @@ std::string to_string(ipv6_subnet x) {
}
} // namespace caf
......@@ -2,8 +2,8 @@
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/config.hpp"
#include "caf/message_handler.hpp"
#include "caf/config.hpp"
namespace caf {
......
......@@ -4,9 +4,9 @@
#include "caf/scoped_actor.hpp"
#include "caf/spawn_options.hpp"
#include "caf/actor_registry.hpp"
#include "caf/scoped_execution_unit.hpp"
#include "caf/spawn_options.hpp"
namespace caf {
......
......@@ -4,8 +4,8 @@
#include "caf/skip.hpp"
#include "caf/result.hpp"
#include "caf/message.hpp"
#include "caf/result.hpp"
namespace caf {
......
......@@ -9,11 +9,11 @@
#include "caf/config.hpp"
#ifdef CAF_WINDOWS
#include <io.h>
#include <windows.h>
# include <io.h>
# include <windows.h>
#else
#include <cstdio>
#include <unistd.h>
# include <cstdio>
# include <unistd.h>
#endif
namespace caf {
......@@ -72,10 +72,10 @@ void set_term_color(std::ostream& out, int c) {
out << '\n';
}
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
# define STDOUT_FILENO 1
# define STDERR_FILENO 2
#define ISATTY_FUN ::_isatty
# define ISATTY_FUN ::_isatty
#else // POSIX-compatible terminals
......@@ -104,7 +104,7 @@ void set_term_color(std::ostream& out, const char* x) {
out << x;
}
#define ISATTY_FUN ::isatty
# define ISATTY_FUN ::isatty
#endif
......
......@@ -11,4 +11,3 @@ thread_hook::~thread_hook() {
}
} // namespace caf
......@@ -48,12 +48,8 @@ private: \
type name##_ = type{}; \
\
public: \
const auto& name() const noexcept { \
return name##_; \
} \
void name(type value) { \
name##_ = std::move(value); \
}
const auto& name() const noexcept { return name##_; } \
void name(type value) { name##_ = std::move(value); }
// A mean data type designed for maximum coverage of the inspect API.
class nasty {
......
......@@ -4,21 +4,20 @@
#pragma once
#include "caf/io/publish.hpp"
#include "caf/io/basp_broker.hpp"
#include "caf/io/broker.hpp"
#include "caf/io/middleman.hpp"
#include "caf/io/unpublish.hpp"
#include "caf/io/basp_broker.hpp"
#include "caf/io/remote_actor.hpp"
#include "caf/io/typed_broker.hpp"
#include "caf/io/receive_policy.hpp"
#include "caf/io/middleman_actor.hpp"
#include "caf/io/publish.hpp"
#include "caf/io/receive_policy.hpp"
#include "caf/io/remote_actor.hpp"
#include "caf/io/system_messages.hpp"
#include "caf/io/typed_broker.hpp"
#include "caf/io/unpublish.hpp"
#include "caf/io/network/protocol.hpp"
#include "caf/io/network/interfaces.hpp"
#include "caf/io/network/multiplexer.hpp"
#include "caf/io/network/protocol.hpp"
#include "caf/io/network/test_multiplexer.hpp"
#include "caf/io/basp/all.hpp"
......@@ -20,7 +20,8 @@ namespace caf {
// -- templates from the parent namespace necessary for defining aliases -------
template <class> class intrusive_ptr;
template <class>
class intrusive_ptr;
namespace io {
......
......@@ -4,8 +4,8 @@
#pragma once
#include <string>
#include <cstdint>
#include <string>
#include "caf/detail/comparable.hpp"
......@@ -79,4 +79,3 @@ protected:
};
} // namespace caf
......@@ -62,8 +62,8 @@ public:
~middleman() override;
/// Tries to open a port for other CAF instances to connect to.
expected<uint16_t>
open(uint16_t port, const char* in = nullptr, bool reuse = false);
expected<uint16_t> open(uint16_t port, const char* in = nullptr,
bool reuse = false);
/// Closes port `port` regardless of whether an actor is published to it.
expected<void> close(uint16_t port);
......@@ -91,9 +91,9 @@ public:
/// on address `addr` and `port`.
/// @returns The actual port the OS uses after `bind()`. If `port == 0`
/// the OS chooses a random high-level port.
expected<uint16_t>
publish_local_groups(uint16_t port, const char* in = nullptr,
bool reuse = false);
expected<uint16_t> publish_local_groups(uint16_t port,
const char* in = nullptr,
bool reuse = false);
/// Unpublishes `whom` by closing `port` or all assigned ports if `port == 0`.
/// @param whom Actor that should be unpublished at `port`.
......@@ -193,9 +193,9 @@ public:
}
template <class Handle, class Rep, class Period>
expected<Handle>
remote_spawn(const node_id& nid, std::string name, message args,
std::chrono::duration<Rep, Period> timeout) {
expected<Handle> remote_spawn(const node_id& nid, std::string name,
message args,
std::chrono::duration<Rep, Period> timeout) {
return remote_spawn<Handle>(nid, std::move(name), std::move(args),
timespan{timeout});
}
......@@ -353,14 +353,14 @@ private:
remote_spawn_impl(const node_id& nid, std::string& name, message& args,
std::set<std::string> s, timespan timeout);
expected<uint16_t>
publish(const strong_actor_ptr& whom, std::set<std::string> sigs,
uint16_t port, const char* cstr, bool ru);
expected<uint16_t> publish(const strong_actor_ptr& whom,
std::set<std::string> sigs, uint16_t port,
const char* cstr, bool ru);
expected<void> unpublish(const actor_addr& whom, uint16_t port);
expected<strong_actor_ptr>
remote_actor(std::set<std::string> ifs, std::string host, uint16_t port);
expected<strong_actor_ptr> remote_actor(std::set<std::string> ifs,
std::string host, uint16_t port);
static int exec_slave_mode(actor_system&, const actor_system_config&);
......
......@@ -47,9 +47,9 @@ public:
/// Tries to create an unbound TCP doorman bound to `port`, optionally
/// accepting only connections from IP address `in`.
/// @warning Do not call from outside the multiplexer's event loop.
virtual expected<doorman_ptr>
new_tcp_doorman(uint16_t port, const char* in = nullptr,
bool reuse_addr = false)
virtual expected<doorman_ptr> new_tcp_doorman(uint16_t port,
const char* in = nullptr,
bool reuse_addr = false)
= 0;
/// Creates a new `datagram_servant` from a native socket handle.
......
......@@ -74,8 +74,8 @@ CAF_IO_EXPORT std::pair<native_socket, native_socket> create_pipe();
/// Sets fd to be inherited by child processes if `new_value == true`
/// or not if `new_value == false`. Not implemented on Windows.
/// throws `network_error` on error
CAF_IO_EXPORT expected<void>
child_process_inherit(native_socket fd, bool new_value);
CAF_IO_EXPORT expected<void> child_process_inherit(native_socket fd,
bool new_value);
/// Enables keepalive on `fd`. Throws `network_error` on error.
CAF_IO_EXPORT expected<void> keepalive(native_socket fd, bool new_value);
......@@ -93,8 +93,8 @@ CAF_IO_EXPORT expected<void> tcp_nodelay(native_socket fd, bool new_value);
CAF_IO_EXPORT expected<void> allow_sigpipe(native_socket fd, bool new_value);
/// Enables or disables `SIO_UDP_CONNRESET`error on `fd`.
CAF_IO_EXPORT expected<void>
allow_udp_connreset(native_socket fd, bool new_value);
CAF_IO_EXPORT expected<void> allow_udp_connreset(native_socket fd,
bool new_value);
/// Get the socket buffer size for `fd`.
CAF_IO_EXPORT expected<int> send_buffer_size(native_socket fd);
......
......@@ -72,9 +72,8 @@ public:
public:
datagram_servant_ptr new_datagram_servant(datagram_handle, uint16_t port);
datagram_servant_ptr new_datagram_servant(datagram_handle,
const std::string& host,
uint16_t port);
datagram_servant_ptr
new_datagram_servant(datagram_handle, const std::string& host, uint16_t port);
void provide_scribe(std::string host, uint16_t desired_port,
connection_handle hdl);
......@@ -183,8 +182,8 @@ public:
/// Stores `hdl` as a pending endpoint for `src`.
void add_pending_endpoint(datagram_handle src, datagram_handle hdl);
using pending_connects_map = std::unordered_multimap<accept_handle,
connection_handle>;
using pending_connects_map
= std::unordered_multimap<accept_handle, connection_handle>;
pending_connects_map& pending_connects();
......@@ -192,13 +191,13 @@ public:
pending_endpoints_map& pending_endpoints();
using pending_scribes_map = std::map<std::pair<std::string, uint16_t>,
connection_handle>;
using pending_scribes_map
= std::map<std::pair<std::string, uint16_t>, connection_handle>;
using pending_doorman_map = std::unordered_map<uint16_t, accept_handle>;
using pending_local_datagram_endpoints_map = std::map<uint16_t,
datagram_handle>;
using pending_local_datagram_endpoints_map
= std::map<uint16_t, datagram_handle>;
using pending_remote_datagram_endpoints_map
= std::map<std::pair<std::string, uint16_t>, datagram_handle>;
......@@ -235,8 +234,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();
......@@ -324,16 +323,15 @@ private:
// the output of another scribe and vice versa.
datagram_data(
shared_job_queue_type input = std::make_shared<write_job_queue_type>(),
shared_job_queue_type output = std::make_shared<write_job_queue_type>()
);
shared_job_queue_type output = std::make_shared<write_job_queue_type>());
};
using scribe_data_map = std::unordered_map<connection_handle, scribe_data>;
using doorman_data_map = std::unordered_map<accept_handle, doorman_data>;
using datagram_data_map = std::unordered_map<datagram_handle,
std::shared_ptr<datagram_data>>;
using datagram_data_map
= std::unordered_map<datagram_handle, std::shared_ptr<datagram_data>>;
// guards resumables_ and scribes_
std::mutex mx_;
......
......@@ -13,14 +13,14 @@
namespace caf::io {
inline expected<group>
remote_group(actor_system& sys, const std::string& group_uri) {
inline expected<group> remote_group(actor_system& sys,
const std::string& group_uri) {
return sys.middleman().remote_group(group_uri);
}
inline expected<group>
remote_group(actor_system& sys, const std::string& group_identifier,
const std::string& host, uint16_t port) {
inline expected<group> remote_group(actor_system& sys,
const std::string& group_identifier,
const std::string& host, uint16_t port) {
return sys.middleman().remote_group(group_identifier, host, port);
}
......
......@@ -5,28 +5,28 @@
#pragma once
#include <map>
#include <vector>
#include <type_traits>
#include <vector>
#include "caf/none.hpp"
#include "caf/config.hpp"
#include "caf/make_counted.hpp"
#include "caf/extend.hpp"
#include "caf/typed_actor.hpp"
#include "caf/local_actor.hpp"
#include "caf/make_counted.hpp"
#include "caf/none.hpp"
#include "caf/typed_actor.hpp"
#include "caf/logger.hpp"
#include "caf/detail/scope_guard.hpp"
#include "caf/actor_registry.hpp"
#include "caf/detail/scope_guard.hpp"
#include "caf/detail/sync_request_bouncer.hpp"
#include "caf/logger.hpp"
#include "caf/mixin/sender.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/mixin/behavior_changer.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/mixin/sender.hpp"
#include "caf/io/abstract_broker.hpp"
#include "caf/io/fwd.hpp"
#include "caf/io/middleman.hpp"
#include "caf/io/abstract_broker.hpp"
namespace caf {
......@@ -71,8 +71,9 @@ public:
using behavior_type = typed_behavior<Sigs...>;
using super = typename extend<abstract_broker, typed_broker<Sigs...>>::
template with<mixin::sender, mixin::requester, mixin::behavior_changer>;
using super =
typename extend<abstract_broker, typed_broker<Sigs...>>::template with<
mixin::sender, mixin::requester, mixin::behavior_changer>;
/// @cond PRIVATE
......@@ -88,7 +89,7 @@ public:
this->init_broker();
auto bhvr = make_behavior();
CAF_LOG_DEBUG_IF(!bhvr, "make_behavior() did not return a behavior:"
<< CAF_ARG2("alive", this->alive()));
<< CAF_ARG2("alive", this->alive()));
if (bhvr) {
// make_behavior() did return a behavior instead of using become()
CAF_LOG_DEBUG("make_behavior() did return a valid behavior");
......@@ -103,17 +104,15 @@ public:
auto sptr = this->take(hdl);
CAF_ASSERT(sptr->hdl() == hdl);
using impl = typename infer_handle_from_fun<F>::impl;
static_assert(std::is_convertible<
typename impl::actor_hdl,
connection_handler
>::value,
"Cannot fork: new broker misses required handlers");
static_assert(
std::is_convertible<typename impl::actor_hdl, connection_handler>::value,
"Cannot fork: new broker misses required handlers");
actor_config cfg{this->context()};
detail::init_fun_factory<impl, F> fac;
cfg.init_fun = fac(std::move(fun), hdl, std::forward<Ts>(xs)...);
using impl = infer_impl_from_fun_t<F>;
static constexpr bool spawnable = detail::spawnable<F, impl, decltype(hdl),
Ts...>();
static constexpr bool spawnable
= detail::spawnable<F, impl, decltype(hdl), Ts...>();
static_assert(spawnable,
"cannot spawn function-based broker with given arguments");
detail::bool_token<spawnable> enabled;
......@@ -124,7 +123,8 @@ public:
return res;
}
expected<connection_handle> add_tcp_scribe(const std::string& host, uint16_t port) {
expected<connection_handle> add_tcp_scribe(const std::string& host,
uint16_t port) {
static_assert(std::is_convertible<actor_hdl, connection_handler>::value,
"Cannot add scribe: broker misses required handlers");
return super::add_tcp_scribe(host, port);
......@@ -137,8 +137,7 @@ public:
}
expected<std::pair<accept_handle, uint16_t>>
add_tcp_doorman(uint16_t port = 0,
const char* in = nullptr,
add_tcp_doorman(uint16_t port = 0, const char* in = nullptr,
bool reuse_addr = false) {
static_assert(std::is_convertible<actor_hdl, accept_handler>::value,
"Cannot add doorman: broker misses required handlers");
......@@ -169,4 +168,3 @@ protected:
} // namespace io
} // namespace caf
......@@ -16,23 +16,23 @@ struct CAF_IO_EXPORT tcp {
/// to `buf`. Returns `true` as long as `fd` is readable and `false`
/// if the socket has been closed or an IO error occurred. The number
/// of read bytes is stored in `result` (can be 0).
static io::network::rw_state
read_some(size_t& result, io::network::native_socket fd, void* buf,
size_t len);
static io::network::rw_state read_some(size_t& result,
io::network::native_socket fd,
void* buf, size_t len);
/// Writes up to `len` bytes from `buf` to `fd`.
/// Returns `true` as long as `fd` is readable and `false`
/// if the socket has been closed or an IO error occurred. The number
/// of written bytes is stored in `result` (can be 0).
static io::network::rw_state
write_some(size_t& result, io::network::native_socket fd, const void* buf,
size_t len);
static io::network::rw_state write_some(size_t& result,
io::network::native_socket fd,
const void* buf, size_t len);
/// Tries to accept a new connection from `fd`. On success,
/// the new connection is stored in `result`. Returns true
/// as long as
static bool
try_accept(io::network::native_socket& result, io::network::native_socket fd);
static bool try_accept(io::network::native_socket& result,
io::network::native_socket fd);
/// Always returns `false`. Native TCP I/O event handlers only rely on the
/// socket buffer.
......
......@@ -16,17 +16,17 @@ struct CAF_IO_EXPORT udp {
/// at the endpoint in `sa` with size `sa_len`. Returns true as long
/// as no IO error occurs. The number of written bytes is stored in
/// `result` and the sender is stored in `ep`.
static bool
read_datagram(size_t& result, io::network::native_socket fd, void* buf,
size_t buf_len, io::network::ip_endpoint& ep);
static bool read_datagram(size_t& result, io::network::native_socket fd,
void* buf, size_t buf_len,
io::network::ip_endpoint& ep);
/// Reveice a datagram of up to `len` bytes. Larger datagrams are truncated.
/// Up to `sender_len` bytes of the receiver address is written into
/// `sender_addr`. Returns `true` if no IO error occurred. The number of
/// received bytes is stored in `result` (can be 0).
static bool
write_datagram(size_t& result, io::network::native_socket fd, void* buf,
size_t buf_len, const io::network::ip_endpoint& ep);
static bool write_datagram(size_t& result, io::network::native_socket fd,
void* buf, size_t buf_len,
const io::network::ip_endpoint& ep);
/// Always returns `false`. Native UDP I/O event handlers only rely on the
/// socket buffer.
......
......@@ -24,8 +24,8 @@ auto autoconnect_timeout = std::chrono::minutes(10);
} // namespace
behavior
connection_helper(stateful_actor<connection_helper_state>* self, actor b) {
behavior connection_helper(stateful_actor<connection_helper_state>* self,
actor b) {
CAF_LOG_TRACE(CAF_ARG(b));
self->monitor(b);
self->set_down_handler([=](down_msg& dm) {
......
......@@ -35,8 +35,8 @@ resumable* pipe_reader::try_read_next() {
std::intptr_t ptrval;
// on windows, we actually have sockets, otherwise we have file handles
#ifdef CAF_WINDOWS
auto res
= recv(fd(), reinterpret_cast<socket_recv_ptr>(&ptrval), sizeof(ptrval), 0);
auto res = recv(fd(), reinterpret_cast<socket_recv_ptr>(&ptrval),
sizeof(ptrval), 0);
#else
auto res = read(fd(), &ptrval, sizeof(ptrval));
#endif
......
......@@ -108,8 +108,8 @@ void receive_buffer::shrink_by(size_t bytes) {
capacity_ = new_size;
}
receive_buffer::iterator
receive_buffer::insert(iterator pos, value_type value) {
receive_buffer::iterator receive_buffer::insert(iterator pos,
value_type value) {
if (size_ == capacity_) {
auto dist = (pos == nullptr) ? 0 : std::distance(begin(), pos);
increase_by(std::max(capacity_, min_size));
......
......@@ -26,8 +26,8 @@ using caf::io::network::socket_size_type;
namespace caf::policy {
rw_state
tcp::read_some(size_t& result, native_socket fd, void* buf, size_t len) {
rw_state tcp::read_some(size_t& result, native_socket fd, void* buf,
size_t len) {
CAF_LOG_TRACE(CAF_ARG(fd) << CAF_ARG(len));
auto sres = ::recv(fd, reinterpret_cast<io::network::socket_recv_ptr>(buf),
len, no_sigpipe_io_flag);
......@@ -47,8 +47,8 @@ tcp::read_some(size_t& result, native_socket fd, void* buf, size_t len) {
return rw_state::success;
}
rw_state
tcp::write_some(size_t& result, native_socket fd, const void* buf, size_t len) {
rw_state tcp::write_some(size_t& result, native_socket fd, const void* buf,
size_t len) {
CAF_LOG_TRACE(CAF_ARG(fd) << CAF_ARG(len));
auto sres = ::send(fd, reinterpret_cast<io::network::socket_send_ptr>(buf),
len, no_sigpipe_io_flag);
......
......@@ -94,8 +94,8 @@ public:
typed_actor_shell_ptr(typed_actor_shell_ptr&& other) noexcept = default;
typed_actor_shell_ptr&
operator=(typed_actor_shell_ptr&& other) noexcept = default;
typed_actor_shell_ptr& operator=(typed_actor_shell_ptr&& other) noexcept
= default;
typed_actor_shell_ptr(const typed_actor_shell_ptr& other) = delete;
......
......@@ -7,4 +7,3 @@
#include "caf/openssl/manager.hpp"
#include "caf/openssl/publish.hpp"
#include "caf/openssl/remote_actor.hpp"
......@@ -9,7 +9,7 @@
namespace caf::openssl {
CAF_OPENSSL_EXPORT io::middleman_actor
make_middleman_actor(actor_system& sys, actor db);
CAF_OPENSSL_EXPORT io::middleman_actor make_middleman_actor(actor_system& sys,
actor db);
} // namespace caf::openssl
......@@ -39,8 +39,8 @@ public:
bool init();
rw_state read_some(size_t& result, native_socket fd, void* buf, size_t len);
rw_state
write_some(size_t& result, native_socket fd, const void* buf, size_t len);
rw_state write_some(size_t& result, native_socket fd, const void* buf,
size_t len);
bool try_connect(native_socket fd);
bool try_accept(native_socket fd);
......
......@@ -77,8 +77,8 @@ struct ssl_policy {
return session_->read_some(result, fd, buf, len);
}
rw_state
write_some(size_t& result, native_socket fd, const void* buf, size_t len) {
rw_state write_some(size_t& result, native_socket fd, const void* buf,
size_t len) {
CAF_LOG_TRACE(CAF_ARG(fd) << CAF_ARG(len));
return session_->write_some(result, fd, buf, len);
}
......@@ -238,8 +238,8 @@ public:
}
protected:
expected<io::scribe_ptr>
connect(const std::string& host, uint16_t port) override {
expected<io::scribe_ptr> connect(const std::string& host,
uint16_t port) override {
CAF_LOG_TRACE(CAF_ARG(host) << CAF_ARG(port));
auto fd = io::network::new_tcp_connection(host, port);
if (!fd)
......@@ -255,8 +255,8 @@ protected:
return make_counted<scribe_impl>(mpx(), *fd, std::move(sssn));
}
expected<io::doorman_ptr>
open(uint16_t port, const char* addr, bool reuse) override {
expected<io::doorman_ptr> open(uint16_t port, const char* addr,
bool reuse) override {
CAF_LOG_TRACE(CAF_ARG(port) << CAF_ARG(reuse));
auto fd = io::network::new_tcp_acceptor_impl(port, addr, reuse);
if (!fd)
......
......@@ -16,9 +16,9 @@ namespace caf::openssl {
/// @param port TCP port.
/// @returns An `actor` to the proxy instance representing
/// a remote actor or an `error`.
expected<strong_actor_ptr>
remote_actor(actor_system& sys, const std::set<std::string>& mpi,
std::string host, uint16_t port) {
expected<strong_actor_ptr> remote_actor(actor_system& sys,
const std::set<std::string>& mpi,
std::string host, uint16_t port) {
CAF_LOG_TRACE(CAF_ARG(mpi) << CAF_ARG(host) << CAF_ARG(port));
expected<strong_actor_ptr> res{strong_actor_ptr{nullptr}};
auto f = make_function_view(sys.openssl_manager().actor_handle());
......
......@@ -72,7 +72,8 @@ struct equality_operator {
|| (std::is_floating_point<U>::value
&& std::is_convertible<T, double>::value))
&& detail::is_comparable<T, U>::value,
int> = 0>
int>
= 0>
bool operator()(const T& t, const U& u) const {
auto x = static_cast<long double>(t);
auto y = static_cast<long double>(u);
......@@ -87,7 +88,8 @@ struct equality_operator {
|| (std::is_floating_point<U>::value
&& std::is_convertible<T, double>::value))
&& detail::is_comparable<T, U>::value,
int> = 0>
int>
= 0>
bool operator()(const T& x, const U& y) const {
return x == y;
}
......
......@@ -23,7 +23,6 @@ using std::endl;
using std::string;
using std::vector;
class host_desc {
public:
std::string host;
......
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