Commit 416ac6bf authored by Dominik Charousset's avatar Dominik Charousset

Apply clang-tidy to codebase

parent 680f9bd7
......@@ -51,7 +51,7 @@ public:
/// @pre `self != nullptr`
/// @pre `policy != nullptr`
abstract_upstream(local_actor* self, policy_ptr policy);
abstract_upstream(local_actor* selfptr, policy_ptr p);
virtual ~abstract_upstream();
......
......@@ -32,7 +32,7 @@ namespace caf {
/// Manages a single stream with any number of down- and upstream actors.
class stream_handler : public ref_counted {
public:
~stream_handler();
~stream_handler() override;
// -- member types -----------------------------------------------------------
......
......@@ -20,6 +20,7 @@
#ifndef CAF_STREAM_MSG_HPP
#define CAF_STREAM_MSG_HPP
#include <utility>
#include <vector>
#include <cstdint>
......@@ -145,8 +146,8 @@ struct stream_msg : tag::boxing_type {
content_type content;
template <class T>
stream_msg(const stream_id& id, T&& x)
: sid(id),
stream_msg(stream_id id, T&& x)
: sid(std::move(id)),
content(std::forward<T>(x)) {
// nop
}
......
......@@ -37,7 +37,7 @@ public:
using result_type = std::pair<error, iterator>;
stream_msg_visitor(scheduled_actor* self, stream_id& sid,
iterator pos, iterator end);
iterator i, iterator last);
result_type operator()(stream_msg::open& x);
......
......@@ -39,7 +39,7 @@ public:
stream_sink(abstract_upstream* in_ptr, strong_actor_ptr&& orig_sender,
std::vector<strong_actor_ptr>&& trailing_stages, message_id mid);
bool done() const;
bool done() const override;
error upstream_batch(strong_actor_ptr& src, size_t xs_size,
message& xs) final;
......
......@@ -35,7 +35,7 @@ class stream_source : public extend<stream_handler, stream_source>::
public:
stream_source(abstract_downstream* out_ptr);
~stream_source();
~stream_source() override;
bool done() const final;
......
......@@ -51,7 +51,7 @@ public:
/// Amount of credit we have signaled upstream.
size_t assigned_credit;
upstream_path(strong_actor_ptr hdl, const stream_id& id, stream_priority p);
upstream_path(strong_actor_ptr ptr, stream_id id, stream_priority p);
};
} // namespace caf
......
......@@ -17,6 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include <utility>
#include "caf/abstract_downstream.hpp"
#include "caf/send.hpp"
......@@ -28,7 +30,9 @@ namespace caf {
abstract_downstream::abstract_downstream(local_actor* selfptr,
const stream_id& sid,
std::unique_ptr<downstream_policy> ptr)
: self_(selfptr), sid_(sid), policy_(std::move(ptr)) {
: self_(selfptr),
sid_(sid),
policy_(std::move(ptr)) {
// nop
}
......
......@@ -71,7 +71,7 @@ public:
}
if (out)
*out << "error in line " << ln
<< ": unrecognized parameter name \"" << name << "\""
<< R"(: unrecognized parameter name ")" << name << R"(")"
<< std::endl;
}
......@@ -268,7 +268,7 @@ actor_system_config& actor_system_config::parse(message& args,
i->second(ln, cv, none);
else
std::cerr << "error in line " << ln
<< ": unrecognized parameter name \"" << nm << "\""
<< R"(: unrecognized parameter name ")" << nm << R"(")"
<< std::endl;
};
actor_system_config_reader consumer{options_, custom_options_, nac_sink};
......
......@@ -80,7 +80,7 @@ pthread_key_t s_key;
pthread_once_t s_key_once = PTHREAD_ONCE_INIT;
void logger_ptr_destructor(void* ptr) {
if (ptr) {
if (ptr != nullptr) {
intrusive_ptr_release(reinterpret_cast<logger*>(ptr));
}
}
......@@ -92,7 +92,7 @@ void make_logger_ptr() {
void set_current_logger(logger* x) {
pthread_once(&s_key_once, make_logger_ptr);
logger_ptr_destructor(pthread_getspecific(s_key));
if (x)
if (x != nullptr)
intrusive_ptr_add_ref(x);
pthread_setspecific(s_key, x);
}
......
......@@ -68,25 +68,23 @@ auto stream_msg_visitor::operator()(stream_msg::open& x) -> result_type {
"handler after receiving token:"
<< CAF_ARG(x.token));
return fail(sec::stream_init_failed);
} else {
auto& handler = i_->second;
// store upstream actor
auto initial_credit = handler->add_upstream(x.prev_stage, sid_, x.priority);
if (initial_credit) {
// check whether we are a stage in a longer pipeline and send more
// stream_open messages if required
auto ic = static_cast<int32_t>(*initial_credit);
std::vector<atom_value> filter;
unsafe_send_as(self_, predecessor,
make_message(make<stream_msg::ack_open>(
std::move(sid_), ic, std::move(filter), false)));
return {none, i_};
} else {
printf("error: %s\n", self_->system().render(initial_credit.error()).c_str());
self_->streams().erase(i_);
return fail(std::move(initial_credit.error()));
}
}
auto& handler = i_->second;
// store upstream actor
auto initial_credit = handler->add_upstream(x.prev_stage, sid_, x.priority);
if (initial_credit) {
// check whether we are a stage in a longer pipeline and send more
// stream_open messages if required
auto ic = static_cast<int32_t>(*initial_credit);
std::vector<atom_value> filter;
unsafe_send_as(self_, predecessor,
make_message(make<stream_msg::ack_open>(
std::move(sid_), ic, std::move(filter), false)));
return {none, i_};
}
printf("error: %s\n", self_->system().render(initial_credit.error()).c_str());
self_->streams().erase(i_);
return fail(std::move(initial_credit.error()));
}
auto stream_msg_visitor::operator()(stream_msg::close&) -> result_type {
......
......@@ -52,12 +52,12 @@ error stream_source::downstream_demand(strong_actor_ptr& hdl, size_t value) {
if (current_size < size_hint)
generate(size_hint - current_size);
return trigger_send(hdl);
} else if(buf_size() > 0) {
// transmit cached elements before closing paths
}
// transmit cached elements before closing paths
if (buf_size() > 0)
return trigger_send(hdl);
} else if (out_ptr_->remove_path(hdl)) {
if (out_ptr_->remove_path(hdl))
return none;
}
}
return sec::invalid_downstream;
}
......
......@@ -56,7 +56,7 @@ error stream_stage::downstream_demand(strong_actor_ptr& hdl, size_t value) {
path->open_credit += value;
if(out_ptr_->buf_size() > 0) {
return trigger_send(hdl);
} else if (in_ptr_->closed()) {
} if (in_ptr_->closed()) {
if (!out_ptr_->remove_path(hdl)) {
return sec::invalid_downstream;
}
......
......@@ -27,7 +27,7 @@
#include <io.h>
#include <windows.h>
#else
#include <stdio.h>
#include <cstdio>
#include <unistd.h>
#endif
......
......@@ -17,14 +17,16 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include <utility>
#include "caf/upstream_path.hpp"
namespace caf {
upstream_path::upstream_path(strong_actor_ptr ptr, const stream_id& id,
upstream_path::upstream_path(strong_actor_ptr ptr, stream_id id,
stream_priority p)
: hdl(std::move(ptr)),
sid(id),
sid(std::move(id)),
prio(p),
last_acked_batch_id(0),
last_batch_id(0),
......
......@@ -98,7 +98,7 @@ behavior filter(event_based_actor* self) {
},
// processing step
[=](unit_t&, downstream<int>& out, int x) {
if (x & 0x01)
if ((x & 0x01) != 0)
out.push(x);
},
// cleanup
......
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