Commit 1146591b authored by Dominik Charousset's avatar Dominik Charousset

Fix formatting

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