Commit fe7fe943 authored by Dominik Charousset's avatar Dominik Charousset

Fix cppcheck warnings

parent 5aa56598
// having an explicit constructor for attachable would
// make it harder to use and its a library internal anyways
noExplicitConstructor:libcaf_core/caf/attachable.hpp
// cppcheck has all kinds of false positives in the optional header,
// mostly const and static suggestions that are flat out wrong and
// would cause compiler error (const optional::destroy?, wtf?)
*:libcaf_core/caf/optional.hpp
// cppcheck fails to recognize the pattern of converting
// `intrusive_ptr<T>` from `intrusive_ptr<U>`
noExplicitConstructor:libcaf_core/caf/intrusive_ptr.hpp
// cppcheck complains about `node_id(const invalid_node_id_t&)`,
// which must not be explicit because `invalid_node_id_t` would
// be completely useless otherwise, the same is true for
// - `message_id(invalid_message_id_t)`
noExplicitConstructor:libcaf_core/caf/node_id.hpp
noExplicitConstructor:libcaf_core/caf/message_id.hpp
// the ctor `duration(std::chrono::duration<Rep, Period> d)`
// is not explicit on purpose
noExplicitConstructor:libcaf_core/caf/duration.hpp
// `operator=(const ref_counted&)` does not assign `rc_`
// on purpose because this would corrupt reference counting
operatorEqVarError:libcaf_core/src/ref_counted.cpp
// cppcheck complains about not initializing the pad members
uninitMemberVar:libcaf_core/caf/detail/double_ended_queue.hpp
// making the policy functions static is technically possible,
// but conceptionally questionable
functionStatic:libcaf_core/caf/policy/work_stealing.hpp
// 6 false positives
*:libcaf_core/caf/detail/limited_vector.hpp
// `test_struct::test_value` is unused since this file tests `announce`
unusedStructMember:libcaf_io/test/uniform_type.cpp
// `exit_reason::as_string` is unused in this .cpp file, but part of the API,
// same is true for other falsely reported unused functions
unusedFunction:libcaf_core/src/exit_reason.cpp
unusedFunction:libcaf_core/src/shared_spinlock.cpp
unusedFunction:libcaf_io/src/interfaces.cpp
unusedFunction:libcaf_io/src/max_msg_size.cpp
......@@ -87,7 +87,7 @@ protected:
private:
// can only be called from abstract_actor and abstract_group
abstract_channel(int init_flags);
explicit abstract_channel(int init_flags);
abstract_channel(int init_flags, node_id nid);
/*
......
......@@ -109,7 +109,7 @@ public:
/// Returns the name of this module implementation.
/// @threadsafe
const std::string& name();
const std::string& name() const;
/// Returns a pointer to the group associated with the name `group_name`.
/// @threadsafe
......
......@@ -79,23 +79,27 @@ protected:
private:
template <class C>
typename std::enable_if<std::is_empty<C>::value, bool>::type
eq(const C&, const C&) const {
static typename std::enable_if<std::is_empty<C>::value, bool>::type
eq(const C&, const C&) {
return true;
}
template <class C>
typename std::enable_if<! std::is_empty<C>::value &&
detail::is_comparable<C, C>::value,
bool>::type
eq(const C& lhs, const C& rhs) const {
static typename std::enable_if<
! std::is_empty<C>::value && detail::is_comparable<C, C>::value,
bool
>::type
eq(const C& lhs, const C& rhs) {
return lhs == rhs;
}
template <class C>
typename std::enable_if<! std::is_empty<C>::value && std::is_pod<C>::value &&
! detail::is_comparable<C, C>::value,
bool>::type
typename std::enable_if<
! std::is_empty<C>::value
&& ! detail::is_comparable<C, C>::value
&& std::is_pod<C>::value,
bool
>::type
eq(const C& lhs, const C& rhs) const {
return pod_mems_equals(lhs, rhs);
}
......
......@@ -65,10 +65,10 @@ public:
size_t count_proxies(const key_type& node);
/// Returns all proxies for `node`.
std::vector<actor_proxy_ptr> get_all();
std::vector<actor_proxy_ptr> get_all() const;
/// Returns all proxies for `node`.
std::vector<actor_proxy_ptr> get_all(const key_type& node);
std::vector<actor_proxy_ptr> get_all(const key_type& node) const;
/// Returns the proxy instance identified by `node` and `aid`
/// or `nullptr` if the actor either unknown or expired.
......
......@@ -108,10 +108,10 @@ private:
bool filter(upgrade_lock<detail::shared_spinlock>&, const actor_addr& sender,
message_id mid, const message& content, execution_unit* host);
// call without mtx_ held
// call without workers_mtx_ held
void quit();
detail::shared_spinlock mtx_;
detail::shared_spinlock workers_mtx_;
std::vector<actor> workers_;
policy policy_;
uint32_t planned_reason_;
......
......@@ -82,7 +82,7 @@ public:
void request_deletion(bool decremented_ref_count) noexcept override;
inline anchor_ptr get_anchor() {
inline anchor_ptr get_anchor() const {
return anchor_;
}
......
......@@ -90,7 +90,7 @@ public:
public:
pointer value;
std::atomic<node*> next;
node(pointer val) : value(val), next(nullptr) {
explicit node(pointer val) : value(val), next(nullptr) {
// nop
}
private:
......@@ -230,7 +230,7 @@ private:
class lock_guard {
public:
lock_guard(std::atomic_flag& lock) : lock_(lock) {
explicit lock_guard(std::atomic_flag& lock) : lock_(lock) {
while (lock.test_and_set(std::memory_order_acquire)) {
std::this_thread::yield();
}
......
......@@ -130,7 +130,7 @@ typename ieee_754_trait<T>::float_type unpack754(T i) {
++shift;
}
// sign it
result *= (i >> (trait::bits - 1)) & 1 ? -1 : 1;
result *= ((i >> (trait::bits - 1)) & 1) ? -1 : 1;
return result;
}
......
......@@ -41,19 +41,16 @@ public:
using trait = typename detail::get_callable_trait<F>::type;
using arg_types = typename trait::arg_types;
using result_type = typename trait::result_type;
constexpr bool returns_behavior =
std::is_convertible<result_type, behavior>::value;
constexpr bool uses_first_arg = std::is_pointer<
typename detail::tl_head<arg_types>::type>::value;
std::integral_constant<bool, returns_behavior> token1;
std::integral_constant<bool, uses_first_arg> token2;
using first_arg = typename detail::tl_head<arg_types>::type;
bool_token<std::is_convertible<result_type, behavior>::value> token1;
bool_token<std::is_pointer<first_arg>::value> token2;
return make(token1, token2, std::move(f), std::forward<Ts>(xs)...);
}
private:
// behavior (pointer)
template <class Fun>
fun make(std::true_type, std::true_type, Fun fun) {
static fun make(std::true_type, std::true_type, Fun fun) {
return [fun](local_actor* ptr) -> behavior {
auto res = fun(static_cast<Base*>(ptr));
return std::move(res.unbox());
......@@ -62,7 +59,7 @@ private:
// void (pointer)
template <class Fun>
fun make(std::false_type, std::true_type, Fun fun) {
static fun make(std::false_type, std::true_type, Fun fun) {
return [fun](local_actor* ptr) -> behavior {
fun(static_cast<Base*>(ptr));
return behavior{};
......@@ -71,7 +68,7 @@ private:
// behavior ()
template <class Fun>
fun make(std::true_type, std::false_type, Fun fun) {
static fun make(std::true_type, std::false_type, Fun fun) {
return [fun](local_actor*) -> behavior {
auto res = fun();
return std::move(res.unbox());
......@@ -80,7 +77,7 @@ private:
// void ()
template <class Fun>
fun make(std::false_type, std::false_type, Fun fun) {
static fun make(std::false_type, std::false_type, Fun fun) {
return [fun](local_actor*) -> behavior {
fun();
return behavior{};
......@@ -88,14 +85,14 @@ private:
}
template <class Token, typename T0, class... Ts>
fun make(Token t1, std::true_type t2, F fun, T0&& x, Ts&&... xs) {
static fun make(Token t1, std::true_type t2, F fun, T0&& x, Ts&&... xs) {
return make(t1, t2,
std::bind(fun, std::placeholders::_1, detail::spawn_fwd<T0>(x),
detail::spawn_fwd<Ts>(xs)...));
}
template <class Token, typename T0, class... Ts>
fun make(Token t1, std::false_type t2, F fun, T0&& x, Ts&&... xs) {
static fun make(Token t1, std::false_type t2, F fun, T0&& x, Ts&&... xs) {
return make(t1, t2, std::bind(fun, detail::spawn_fwd<T0>(x),
detail::spawn_fwd<Ts>(xs)...));
}
......
......@@ -32,11 +32,8 @@
namespace caf {
namespace detail {
/*
* A vector with a fixed maximum size (uses an array internally).
* @warning This implementation is highly optimized for arithmetic types and
* does <b>not</b> call constructors or destructors.
*/
// A vector with a fixed maximum size (uses an array internally).
// @warning This implementation is highly optimized for arithmetic types and
template <class T, size_t MaxSize>
class limited_vector {
public:
......@@ -56,7 +53,7 @@ public:
// nop
}
limited_vector(size_t initial_size) : size_(initial_size) {
explicit limited_vector(size_t initial_size) : size_(initial_size) {
T tmp;
std::fill_n(begin(), initial_size, tmp);
}
......@@ -76,7 +73,7 @@ public:
size_ = s;
}
limited_vector(std::initializer_list<T> init) : size_(init.size()) {
explicit limited_vector(std::initializer_list<T> init) : size_(init.size()) {
CAF_ASSERT(init.size() <= MaxSize);
std::copy(init.begin(), init.end(), begin());
}
......
......@@ -33,6 +33,12 @@
namespace caf {
namespace detail {
template <bool X>
using bool_token = std::integral_constant<bool, X>;
template <int X>
using int_token = std::integral_constant<int, X>;
/// Joins all bool constants using operator &&.
template <bool... BoolConstants>
struct conjunction;
......
......@@ -49,7 +49,6 @@ template <class T0, typename T1 = unit_t, typename T2 = unit_t,
typename T15 = unit_t, typename T16 = unit_t, typename T17 = unit_t,
typename T18 = unit_t, typename T19 = unit_t, typename T20 = unit_t>
struct variant_data {
union {
T0 v0; T1 v1; T2 v2;
T3 v3; T4 v4; T5 v5;
......@@ -60,9 +59,13 @@ struct variant_data {
T18 v18; T19 v19; T20 v20;
};
variant_data() { }
variant_data() {
// nop
}
~variant_data() { }
~variant_data() {
// nop
}
CAF_VARIANT_DATA_GETTER(0)
CAF_VARIANT_DATA_GETTER(1)
......@@ -85,20 +88,15 @@ struct variant_data {
CAF_VARIANT_DATA_GETTER(18)
CAF_VARIANT_DATA_GETTER(19)
CAF_VARIANT_DATA_GETTER(20)
private:
template <class M, typename U>
inline void cr(M& member, U&& arg) {
new (&member) M (std::forward<U>(arg));
}
};
struct variant_data_destructor {
using result_type = void;
template <class T>
inline void operator()(T& storage) const { storage.~T(); }
void operator()(T& storage) const {
storage.~T();
}
};
} // namespace detail
......
......@@ -29,9 +29,7 @@ namespace caf {
/// Base class for exceptions.
class caf_exception : public std::exception {
public:
~caf_exception() noexcept;
caf_exception() = delete;
......@@ -42,28 +40,18 @@ public:
const char* what() const noexcept;
protected:
/// Creates an exception with the error string `what_str`.
caf_exception(std::string&& what_str);
/// Creates an exception with the error string `what_str`.
caf_exception(const std::string& what_str);
explicit caf_exception(std::string what_str);
private:
std::string what_;
};
/// Thrown if an actor finished execution.
class actor_exited : public caf_exception {
public:
~actor_exited() noexcept;
actor_exited(uint32_t exit_reason);
explicit actor_exited(uint32_t exit_reason);
actor_exited(const actor_exited&) = default;
actor_exited& operator=(const actor_exited&) = default;
......@@ -71,42 +59,29 @@ public:
inline uint32_t reason() const noexcept;
private:
uint32_t reason_;
};
/// Thrown to indicate that either an actor publishing failed or
/// the middleman was unable to connect to a remote host.
class network_error : public caf_exception {
using super = caf_exception;
public:
~network_error() noexcept;
network_error(std::string&& what_str);
network_error(const std::string& what_str);
explicit network_error(std::string&& what_str);
explicit network_error(const std::string& what_str);
network_error(const network_error&) = default;
network_error& operator=(const network_error&) = default;
};
/// Thrown to indicate that an actor publishing failed because
/// the requested port could not be used.
class bind_failure : public network_error {
using super = network_error;
public:
~bind_failure() noexcept;
bind_failure(std::string&& what_str);
bind_failure(const std::string& what_str);
explicit bind_failure(std::string&& what_str);
explicit bind_failure(const std::string& what_str);
bind_failure(const bind_failure&) = default;
bind_failure& operator=(const bind_failure&) = default;
};
inline uint32_t actor_exited::reason() const noexcept {
......
......@@ -366,7 +366,7 @@ public:
}
/// Checks wheter this actor has a user-defined sync failure handler.
inline bool has_sync_failure_handler() {
inline bool has_sync_failure_handler() const {
return static_cast<bool>(sync_failure_handler_);
}
......@@ -466,13 +466,11 @@ public:
// returns 0 if last_dequeued() is an asynchronous or sync request message,
// a response id generated from the request id otherwise
inline message_id get_response_id() {
inline message_id get_response_id() const {
auto mid = current_element_->mid;
return (mid.is_request()) ? mid.response_id() : message_id();
}
void reply_message(message&& what);
void forward_message(const actor& dest, message_priority mp);
inline uint32_t planned_exit_reason() const {
......@@ -491,7 +489,7 @@ public:
return mailbox_;
}
inline bool has_behavior() {
inline bool has_behavior() const {
return ! bhvr_stack_.empty() || ! pending_responses_.empty();
}
......@@ -599,7 +597,7 @@ private:
typename std::enable_if<
! std::is_same<typename std::decay<T>::type, message>::value
>::type
send_impl(message_id mid, abstract_channel* dest, T&& x, Ts&&... xs) {
send_impl(message_id mid, abstract_channel* dest, T&& x, Ts&&... xs) const {
if (! dest) {
return;
}
......@@ -610,7 +608,7 @@ private:
host());
}
void send_impl(message_id mp, abstract_channel* dest, message what);
void send_impl(message_id mp, abstract_channel* dest, message what) const;
void delayed_send_impl(message_id mid, const channel& whom,
const duration& rtime, message data);
......
......@@ -70,7 +70,7 @@ public:
using lockable = UpgradeLockable;
template <class LockType>
upgrade_to_unique_lock(LockType& other) {
explicit upgrade_to_unique_lock(LockType& other) {
lockable_ = other.release();
if (lockable_) lockable_->unlock_upgrade_and_lock();
}
......
......@@ -289,19 +289,6 @@ public:
return vals_->tuple_type_names();
}
struct move_from_tuple_helper {
template <class... Ts>
inline message operator()(Ts&... xs) {
return make_message(std::move(xs)...);
}
};
template <class... Ts>
inline message move_from_tuple(std::tuple<Ts...>&& tup) {
move_from_tuple_helper f;
return detail::apply_args(f, detail::get_indices(tup), tup);
}
bool match_element(size_t p, uint16_t tnr, const std::type_info* rtti) const;
template <class T, class... Ts>
......@@ -314,8 +301,8 @@ public:
private:
template <size_t P>
bool match_elements_impl(std::integral_constant<size_t, P>,
detail::type_list<>) const {
static bool match_elements_impl(std::integral_constant<size_t, P>,
detail::type_list<>) {
return true; // end of recursion
}
......@@ -406,29 +393,29 @@ inline message make_message(message other) {
template <class T>
message::cli_arg::cli_arg(std::string nstr, std::string tstr, T& arg)
: name(std::move(nstr)),
text(std::move(tstr)) {
fun = [&arg](const std::string& str) -> bool {
text(std::move(tstr)),
fun([&arg](const std::string& str) -> bool {
auto res = from_string<T>(str);
if (! res) {
if (! res)
return false;
}
arg = *res;
return true;
};
}) {
// nop
}
template <class T>
message::cli_arg::cli_arg(std::string nstr, std::string tstr, std::vector<T>& arg)
: name(std::move(nstr)),
text(std::move(tstr)) {
fun = [&arg](const std::string& str) -> bool {
text(std::move(tstr)),
fun([&arg](const std::string& str) -> bool {
auto res = from_string<T>(str);
if (! res) {
if (! res)
return false;
}
arg.push_back(*res);
return true;
};
}) {
// nop
}
} // namespace caf
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_MIXIN_TYPED_FUNCTOR_BASED_HPP
#define CAF_MIXIN_TYPED_FUNCTOR_BASED_HPP
namespace caf {
namespace mixin {
template <class Base, class Subtype>
class typed_functor_based : public Base {
public:
using combined_type = typed_functor_based;
using pointer = Base*;
using behavior_type = typename Base::behavior_type;
using make_behavior_fun = std::function<behavior_type(pointer)>;
using void_fun = std::function<void(pointer)>;
typed_functor_based() {
// nop
}
template <class F, class... Ts>
typed_functor_based(F f, Ts&&... xs) {
init(std::move(f), std::forward<Ts>(xs)...);
}
template <class F, class... Ts>
void init(F f, Ts&&... xs) {
using trait = typename detail::get_callable_trait<F>::type;
using arg_types = typename trait::arg_types;
using result_type = typename trait::result_type;
constexpr bool returns_behavior =
std::is_convertible<result_type, behavior_type>::value;
constexpr bool uses_first_arg = std::is_same<
typename detail::tl_head<arg_types>::type, pointer>::value;
std::integral_constant<bool, returns_behavior> token1;
std::integral_constant<bool, uses_first_arg> token2;
set(token1, token2, std::move(f), std::forward<Ts>(xs)...);
}
protected:
make_behavior_fun m_make_behavior;
private:
template <class F>
void set(std::true_type, std::true_type, F&& fun) {
// behavior_type (pointer)
m_make_behavior = std::forward<F>(fun);
}
template <class F>
void set(std::false_type, std::true_type, F fun) {
// void (pointer)
m_make_behavior = [fun](pointer ptr) {
fun(ptr);
return behavior_type{};
};
}
template <class F>
void set(std::true_type, std::false_type, F fun) {
// behavior_type (void)
m_make_behavior = [fun](pointer) { return fun(); };
}
template <class F>
void set(std::false_type, std::false_type, F fun) {
// void (void)
m_make_behavior = [fun](pointer) {
fun();
return behavior_type{};
};
}
template <class Token, typename F, typename T0, class... Ts>
void set(Token t1, std::true_type t2, F fun, T0&& x, Ts&&... xs) {
set(t1, t2, std::bind(fun, std::placeholders::_1, std::forward<T0>(x),
std::forward<Ts>(xs)...));
}
template <class Token, typename F, typename T0, class... Ts>
void set(Token t1, std::false_type t2, F fun, T0&& x, Ts&&... xs) {
set(t1, t2, std::bind(fun, std::forward<T0>(x), std::forward<Ts>(xs)...));
}
};
} // namespace mixin
} // namespace caf
#endif // CAF_MIXIN_TYPED_FUNCTOR_BASED_HPP
......@@ -79,7 +79,7 @@ public:
// Convenience function to access the data field.
template <class WorkerOrCoordinator>
auto d(WorkerOrCoordinator* self) -> decltype(self->data()) {
static auto d(WorkerOrCoordinator* self) -> decltype(self->data()) {
return self->data();
}
......
......@@ -248,11 +248,8 @@ private:
template <class T, class... Us>
T& get(variant<Us...>& value) {
using namespace detail;
constexpr int type_id = tl_find_if<
type_list<Us...>,
tbind<is_same_ish, T>::template type
>::value;
std::integral_constant<int, type_id> token;
int_token<tl_find_if<type_list<Us...>,
tbind<is_same_ish, T>::template type>::value> token;
// silence compiler error about "binding to unrelated types" such as
// 'signed char' to 'char' (which is obvious bullshit)
return reinterpret_cast<T&>(value.get(token));
......@@ -269,14 +266,10 @@ const T& get(const variant<Us...>& value) {
template <class T, class... Us>
T* get(variant<Us...>* value) {
using namespace detail;
constexpr int type_id = tl_find_if<
type_list<Us...>,
tbind<is_same_ish, T>::template type
>::value;
std::integral_constant<int, type_id> token;
if (value->is(token)) {
int_token<tl_find_if<type_list<Us...>,
tbind<is_same_ish, T>::template type>::value> token;
if (value->is(token))
return &get<T>(*value);
}
return nullptr;
}
......
......@@ -55,7 +55,7 @@ void abstract_group::module::stop() {
CAF_LOG_TRACE("");
}
const std::string& abstract_group::module::name() {
const std::string& abstract_group::module::name() const {
return name_;
}
......
......@@ -87,7 +87,7 @@ size_t actor_namespace::count_proxies(const key_type& node) {
return (i != proxies_.end()) ? i->second.size() : 0;
}
std::vector<actor_proxy_ptr> actor_namespace::get_all() {
std::vector<actor_proxy_ptr> actor_namespace::get_all() const {
std::vector<actor_proxy_ptr> result;
for (auto& outer : proxies_) {
for (auto& inner : outer.second) {
......@@ -100,15 +100,18 @@ std::vector<actor_proxy_ptr> actor_namespace::get_all() {
return result;
}
std::vector<actor_proxy_ptr> actor_namespace::get_all(const key_type& node) {
std::vector<actor_proxy_ptr>
actor_namespace::get_all(const key_type& node) const {
std::vector<actor_proxy_ptr> result;
auto& submap = proxies_[node];
auto i = proxies_.find(node);
if (i == proxies_.end())
return result;
auto& submap = i->second;
for (auto& kvp : submap) {
auto ptr = kvp.second->get();
if (ptr) {
if (ptr)
result.push_back(std::move(ptr));
}
}
return result;
}
......
......@@ -29,8 +29,10 @@
namespace caf {
actor_ostream::actor_ostream(actor self) : self_(std::move(self)) {
printer_ = detail::singletons::get_scheduling_coordinator()->printer();
actor_ostream::actor_ostream(actor self)
: self_(std::move(self)),
printer_(detail::singletons::get_scheduling_coordinator()->printer()) {
// nop
}
actor_ostream& actor_ostream::write(std::string arg) {
......
......@@ -113,7 +113,7 @@ actor actor_pool::make(size_t num_workers, factory fac, policy pol) {
void actor_pool::enqueue(const actor_addr& sender, message_id mid,
message content, execution_unit* eu) {
upgrade_lock<detail::shared_spinlock> guard{mtx_};
upgrade_lock<detail::shared_spinlock> guard{workers_mtx_};
if (filter(guard, sender, mid, content, eu)) {
return;
}
......@@ -122,7 +122,7 @@ void actor_pool::enqueue(const actor_addr& sender, message_id mid,
}
void actor_pool::enqueue(mailbox_element_ptr what, execution_unit* eu) {
upgrade_lock<detail::shared_spinlock> guard{mtx_};
upgrade_lock<detail::shared_spinlock> guard{workers_mtx_};
if (filter(guard, what->sender, what->mid, what->msg, eu)) {
return;
}
......@@ -219,7 +219,7 @@ bool actor_pool::filter(upgrade_lock<detail::shared_spinlock>& guard,
void actor_pool::quit() {
// we can safely run our cleanup code here without holding
// mtx_ because abstract_actor has its own lock
// workers_mtx_ because abstract_actor has its own lock
cleanup(planned_reason_);
is_registered(false);
}
......
......@@ -47,12 +47,7 @@ caf_exception::~caf_exception() noexcept {
// nop
}
caf_exception::caf_exception(const std::string& what_str) : what_(what_str) {
// nop
}
caf_exception::caf_exception(std::string&& what_str)
: what_(std::move(what_str)) {
caf_exception::caf_exception(std::string x) : what_(std::move(x)) {
// nop
}
......@@ -64,15 +59,15 @@ actor_exited::~actor_exited() noexcept {
// nop
}
actor_exited::actor_exited(uint32_t rsn) : caf_exception(ae_what(rsn)) {
reason_ = rsn;
actor_exited::actor_exited(uint32_t x) : caf_exception(ae_what(x)) {
reason_ = x;
}
network_error::network_error(const std::string& str) : super(str) {
network_error::network_error(const std::string& x) : caf_exception(x) {
// nop
}
network_error::network_error(std::string&& str) : super(std::move(str)) {
network_error::network_error(std::string&& x) : caf_exception(std::move(x)) {
// nop
}
......@@ -80,11 +75,11 @@ network_error::~network_error() noexcept {
// nop
}
bind_failure::bind_failure(const std::string& str) : super(str) {
bind_failure::bind_failure(const std::string& x) : network_error(x) {
// nop
}
bind_failure::bind_failure(std::string&& str) : super(std::move(str)) {
bind_failure::bind_failure(std::string&& x) : network_error(std::move(x)) {
// nop
}
......
......@@ -108,21 +108,6 @@ std::vector<group> local_actor::joined_groups() const {
return result;
}
void local_actor::reply_message(message&& what) {
auto& whom = current_element_->sender;
if (! whom) {
return;
}
auto& mid = current_element_->mid;
if (mid.valid() == false || mid.is_response()) {
send(actor_cast<channel>(whom), std::move(what));
} else if (! mid.is_answered()) {
auto ptr = actor_cast<actor>(whom);
ptr->enqueue(address(), mid.response_id(), std::move(what), host());
mid.mark_as_answered();
}
}
void local_actor::forward_message(const actor& dest, message_priority prio) {
if (! dest) {
return;
......@@ -807,7 +792,7 @@ void local_actor::await_data() {
}
void local_actor::send_impl(message_id mid, abstract_channel* dest,
message what) {
message what) const {
if (! dest) {
return;
}
......
......@@ -311,20 +311,23 @@ message::cli_arg::cli_arg(std::string nstr, std::string tstr)
message::cli_arg::cli_arg(std::string nstr, std::string tstr, std::string& arg)
: name(std::move(nstr)),
text(std::move(tstr)) {
fun = [&arg](const std::string& str) -> bool {
text(std::move(tstr)),
fun([&arg](const std::string& str) -> bool {
arg = str;
return true;
};
}) {
// nop
}
message::cli_arg::cli_arg(std::string nstr, std::string tstr,
std::vector<std::string>& arg)
: name(std::move(nstr)), text(std::move(tstr)) {
fun = [&arg](const std::string& str) -> bool {
: name(std::move(nstr)),
text(std::move(tstr)),
fun([&arg](const std::string& str) -> bool {
arg.push_back(str);
return true;
};
}) {
// nop
}
message message::concat_impl(std::initializer_list<data_ptr> xs) {
......
......@@ -34,7 +34,7 @@ ref_counted::ref_counted(const ref_counted&) : rc_(1) {
}
ref_counted& ref_counted::operator=(const ref_counted&) {
// nop; don't copy reference count
// nop; intentionally don't copy reference count
return *this;
}
......
......@@ -38,8 +38,6 @@
#include "caf/detail/actor_registry.hpp"
#include "caf/detail/sync_request_bouncer.hpp"
#include "caf/mixin/typed_functor_based.hpp"
#include "caf/io/middleman.hpp"
#include "caf/io/abstract_broker.hpp"
......
......@@ -40,9 +40,9 @@ public:
handle(const handle& other) = default;
Subtype& operator=(const handle& other) {
handle& operator=(const handle& other) {
id_ = other.id();
return *static_cast<Subtype*>(this);
return *this;
}
/// Returns the unique identifier of this handle.
......
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