Commit 184e0866 authored by Dominik Charousset's avatar Dominik Charousset Committed by Marian Triebe

Apply clang-tidy to codebase

parent 288470f3
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,modernize-*,performance-*,readability-*,-readability-braces-around-statements,-readability-named-parameter'
WarningsAsErrors: ''
HeaderFilterRegex: '/caf/'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: cert-oop11-cpp.UseCERTSemantics
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...
...@@ -137,7 +137,7 @@ void protobuf_io(broker* self, connection_handle hdl, const actor& buddy) { ...@@ -137,7 +137,7 @@ void protobuf_io(broker* self, connection_handle hdl, const actor& buddy) {
self->become(await_length_prefix); self->become(await_length_prefix);
} }
behavior server(broker* self, actor buddy) { behavior server(broker* self, const actor& buddy) {
print_on_exit(self, "server"); print_on_exit(self, "server");
aout(self) << "server is running" << endl; aout(self) << "server is running" << endl;
return { return {
......
/******************************************************************************\ /******************************************************************************
* This example * * This example *
* - emulates a client launching a request every 10-300ms * * - emulates a client launching a request every 10-300ms *
* - uses a CURL-backend consisting of a master and 10 workers * * - uses a CURL-backend consisting of a master and 10 workers *
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
* | |<--/ * * | |<--/ *
* | <-------------(reply)-------------- | * * | <-------------(reply)-------------- | *
* X * * X *
\ ******************************************************************************/ ******************************************************************************/
// C includes // C includes
#include <time.h> #include <ctime>
#include <signal.h> #include <csignal>
#include <stdlib.h> #include <cstdlib>
// C++ includes // C++ includes
#include <string> #include <string>
...@@ -129,7 +129,7 @@ struct base_state { ...@@ -129,7 +129,7 @@ struct base_state {
}; };
// encapsulates an HTTP request // encapsulates an HTTP request
behavior client_job(stateful_actor<base_state>* self, actor parent) { behavior client_job(stateful_actor<base_state>* self, const actor& parent) {
if (!self->state.init("client-job", color::blue)) if (!self->state.init("client-job", color::blue))
return {}; // returning an empty behavior terminates the actor return {}; // returning an empty behavior terminates the actor
self->send(parent, read_atom::value, self->send(parent, read_atom::value,
...@@ -164,7 +164,7 @@ struct client_state : base_state { ...@@ -164,7 +164,7 @@ struct client_state : base_state {
}; };
// spawns HTTP requests // spawns HTTP requests
behavior client(stateful_actor<client_state>* self, actor parent) { behavior client(stateful_actor<client_state>* self, const actor& parent) {
using std::chrono::milliseconds; using std::chrono::milliseconds;
self->link_to(parent); self->link_to(parent);
if (!self->state.init("client", color::green)) if (!self->state.init("client", color::green))
...@@ -190,8 +190,8 @@ struct curl_state : base_state { ...@@ -190,8 +190,8 @@ struct curl_state : base_state {
// nop // nop
} }
~curl_state() { ~curl_state() override {
if (curl) if (curl != nullptr)
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }
...@@ -206,7 +206,7 @@ struct curl_state : base_state { ...@@ -206,7 +206,7 @@ struct curl_state : base_state {
bool init(std::string m_name, std::string m_color) override { bool init(std::string m_name, std::string m_color) override {
curl = curl_easy_init(); curl = curl_easy_init();
if (!curl) if (curl == nullptr)
return false; return false;
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_state::callback); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_state::callback);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
...@@ -218,7 +218,7 @@ struct curl_state : base_state { ...@@ -218,7 +218,7 @@ struct curl_state : base_state {
}; };
// manages a CURL session // manages a CURL session
behavior curl_worker(stateful_actor<curl_state>* self, actor parent) { behavior curl_worker(stateful_actor<curl_state>* self, const actor& parent) {
if (!self->state.init("curl-worker", color::yellow)) if (!self->state.init("curl-worker", color::yellow))
return {}; // returning an empty behavior terminates the actor return {}; // returning an empty behavior terminates the actor
return { return {
...@@ -340,7 +340,7 @@ void caf_main(actor_system& system) { ...@@ -340,7 +340,7 @@ void caf_main(actor_system& system) {
struct sigaction act; struct sigaction act;
act.sa_handler = [](int) { shutdown_flag = true; }; act.sa_handler = [](int) { shutdown_flag = true; };
auto set_sighandler = [&] { auto set_sighandler = [&] {
if (sigaction(SIGINT, &act, 0)) { if (sigaction(SIGINT, &act, nullptr) != 0) {
std::cerr << "fatal: cannot set signal handler" << std::endl; std::cerr << "fatal: cannot set signal handler" << std::endl;
abort(); abort();
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <map> #include <map>
#include <thread> #include <thread>
#include <utility>
#include <vector> #include <vector>
#include <chrono> #include <chrono>
#include <sstream> #include <sstream>
...@@ -34,7 +35,8 @@ using think_atom = atom_constant<atom("think")>; ...@@ -34,7 +35,8 @@ using think_atom = atom_constant<atom("think")>;
using chopstick = typed_actor<replies_to<take_atom>::with<taken_atom, bool>, using chopstick = typed_actor<replies_to<take_atom>::with<taken_atom, bool>,
reacts_to<put_atom>>; reacts_to<put_atom>>;
chopstick::behavior_type taken_chopstick(chopstick::pointer, strong_actor_ptr); chopstick::behavior_type taken_chopstick(chopstick::pointer,
const strong_actor_ptr&);
// either taken by a philosopher or available // either taken by a philosopher or available
chopstick::behavior_type available_chopstick(chopstick::pointer self) { chopstick::behavior_type available_chopstick(chopstick::pointer self) {
...@@ -50,7 +52,7 @@ chopstick::behavior_type available_chopstick(chopstick::pointer self) { ...@@ -50,7 +52,7 @@ chopstick::behavior_type available_chopstick(chopstick::pointer self) {
} }
chopstick::behavior_type taken_chopstick(chopstick::pointer self, chopstick::behavior_type taken_chopstick(chopstick::pointer self,
strong_actor_ptr user) { const strong_actor_ptr& user) {
return { return {
[](take_atom) -> std::tuple<taken_atom, bool> { [](take_atom) -> std::tuple<taken_atom, bool> {
return std::make_tuple(taken_atom::value, false); return std::make_tuple(taken_atom::value, false);
...@@ -94,13 +96,13 @@ chopstick::behavior_type taken_chopstick(chopstick::pointer self, ...@@ -94,13 +96,13 @@ chopstick::behavior_type taken_chopstick(chopstick::pointer self,
class philosopher : public event_based_actor { class philosopher : public event_based_actor {
public: public:
philosopher(actor_config& cfg, philosopher(actor_config& cfg,
const std::string& n, std::string n,
const chopstick& l, chopstick l,
const chopstick& r) chopstick r)
: event_based_actor(cfg), : event_based_actor(cfg),
name_(n), name_(std::move(n)),
left_(l), left_(std::move(l)),
right_(r) { right_(std::move(r)) {
// we only accept one message per state and skip others in the meantime // we only accept one message per state and skip others in the meantime
set_default_handler(skip); set_default_handler(skip);
// a philosopher that receives {eat} stops thinking and becomes hungry // a philosopher that receives {eat} stops thinking and becomes hungry
......
...@@ -12,7 +12,7 @@ using namespace caf; ...@@ -12,7 +12,7 @@ using namespace caf;
using calc = typed_actor<replies_to<add_atom, int, int>::with<int>>; using calc = typed_actor<replies_to<add_atom, int, int>::with<int>>;
void actor_a(event_based_actor* self, calc worker) { void actor_a(event_based_actor* self, const calc& worker) {
self->request(worker, std::chrono::seconds(10), add_atom::value, 1, 2).then( self->request(worker, std::chrono::seconds(10), add_atom::value, 1, 2).then(
[=](int result) { [=](int result) {
aout(self) << "1 + 2 = " << result << endl; aout(self) << "1 + 2 = " << result << endl;
...@@ -20,7 +20,7 @@ void actor_a(event_based_actor* self, calc worker) { ...@@ -20,7 +20,7 @@ void actor_a(event_based_actor* self, calc worker) {
); );
} }
calc::behavior_type actor_b(calc::pointer self, calc worker) { calc::behavior_type actor_b(calc::pointer self, const calc& worker) {
return { return {
[=](add_atom add, int x, int y) { [=](add_atom add, int x, int y) {
return self->delegate(worker, add, x, y); return self->delegate(worker, add, x, y);
......
/******************************************************************************\
* This example is an implementation of the classical Dining Philosophers *
* exercise using only libcaf's event-based actor implementation. *
\ ******************************************************************************/
#include <map>
#include <thread>
#include <vector>
#include <chrono>
#include <sstream>
#include <iostream>
namespace std {
string to_string(const thread::id& x) {
ostringstream os;
os << x;
return os.str();
}
}
#include "caf/all.hpp"
using std::cout;
using std::cerr;
using std::endl;
using std::chrono::seconds;
using namespace caf;
namespace {
// atoms for chopstick interface
using put_atom = atom_constant<atom("put")>;
using take_atom = atom_constant<atom("take")>;
using taken_atom = atom_constant<atom("taken")>;
// atoms for philosopher interface
using eat_atom = atom_constant<atom("eat")>;
using think_atom = atom_constant<atom("think")>;
// a chopstick
using chopstick = typed_actor<replies_to<take_atom>::with<taken_atom, bool>,
reacts_to<put_atom>>;
chopstick::behavior_type taken_chopstick(chopstick::pointer self, actor_addr);
// either taken by a philosopher or available
chopstick::behavior_type available_chopstick(chopstick::pointer self) {
return {
[=](take_atom) -> std::tuple<taken_atom, bool> {
self->become(taken_chopstick(self, self->current_sender()));
return std::make_tuple(taken_atom::value, true);
},
[](put_atom) {
cerr << "chopstick received unexpected 'put'" << endl;
}
};
}
chopstick::behavior_type taken_chopstick(chopstick::pointer self,
actor_addr user) {
return {
[](take_atom) -> std::tuple<taken_atom, bool> {
return std::make_tuple(taken_atom::value, false);
},
[=](put_atom) {
if (self->current_sender() == user)
self->become(available_chopstick(self));
}
};
}
/* Based on: http://www.dalnefre.com/wp/2010/08/dining-philosophers-in-humus/
*
*
* +-------------+ {busy|taken}
* /-------->| thinking |<------------------\
* | +-------------+ |
* | | |
* | | {eat} |
* | | |
* | V |
* | +-------------+ {busy} +-------------+
* | | hungry |----------->| denied |
* | +-------------+ +-------------+
* | |
* | | {taken}
* | |
* | V
* | +-------------+
* | | granted |
* | +-------------+
* | | |
* | {busy} | | {taken}
* \-----------/ |
* | V
* | {think} +-------------+
* \---------| eating |
* +-------------+
*/
class philosopher : public event_based_actor {
public:
philosopher(actor_config& cfg,
const std::string& n,
const chopstick& l,
const chopstick& r)
: event_based_actor(cfg),
name(n),
left(l),
right(r) {
// a philosopher that receives {eat} stops thinking and becomes hungry
thinking.assign(
[=](eat_atom) {
become(hungry);
send(left, take_atom::value);
send(right, take_atom::value);
}
);
// wait for the first answer of a chopstick
hungry.assign(
[=](taken_atom, bool result) {
if (result)
become(granted);
else
become(denied);
}
);
// philosopher was able to obtain the first chopstick
granted.assign(
[=](taken_atom, bool result) {
if (result) {
aout(this) << name
<< " has picked up chopsticks with IDs "
<< left->id() << " and " << right->id()
<< " and starts to eat\n";
// eat some time
delayed_send(this, seconds(5), think_atom::value);
become(eating);
} else {
send(current_sender() == left ? right : left, put_atom::value);
send(this, eat_atom::value);
become(thinking);
}
}
);
// philosopher was *not* able to obtain the first chopstick
denied.assign(
[=](taken_atom, bool result) {
if (result)
send(current_sender() == left ? left : right, put_atom::value);
send(this, eat_atom::value);
become(thinking);
}
);
// philosopher obtained both chopstick and eats (for five seconds)
eating.assign(
[=](think_atom) {
send(left, put_atom::value);
send(right, put_atom::value);
delayed_send(this, seconds(5), eat_atom::value);
aout(this) << name << " puts down his chopsticks and starts to think\n";
become(thinking);
}
);
}
protected:
behavior make_behavior() override {
// start thinking
send(this, think_atom::value);
// philosophers start to think after receiving {think}
return (
[=](think_atom) {
aout(this) << name << " starts to think\n";
delayed_send(this, seconds(5), eat_atom::value);
become(thinking);
}
);
}
private:
std::string name; // the name of this philosopher
chopstick left; // left chopstick
chopstick right; // right chopstick
behavior thinking; // initial behavior
behavior hungry; // tries to take chopsticks
behavior granted; // has one chopstick and waits for the second one
behavior denied; // could not get first chopsticks
behavior eating; // wait for some time, then go thinking again
};
} // namespace <anonymous>
int main(int, char**) {
actor_system system;
scoped_actor self{system};
// create five chopsticks
aout(self) << "chopstick ids are:";
std::vector<chopstick> chopsticks;
for (size_t i = 0; i < 5; ++i) {
chopsticks.push_back(self->spawn(available_chopstick));
aout(self) << " " << chopsticks.back()->id();
}
aout(self) << endl;
// spawn five philosophers
std::vector<std::string> names {"Plato", "Hume", "Kant",
"Nietzsche", "Descartes"};
for (size_t i = 0; i < 5; ++i)
self->spawn<philosopher>(names[i], chopsticks[i], chopsticks[(i + 1) % 5]);
}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
// Run client at the same host: // Run client at the same host:
// - ./build/bin/distributed_math_actor -c -p 4242 // - ./build/bin/distributed_math_actor -c -p 4242
// Manual refs: 221-233 (ConfiguringActorSystems) // Manual refs: 222-234 (ConfiguringActorSystems)
#include <array> #include <array>
#include <vector> #include <vector>
...@@ -31,7 +31,7 @@ using namespace caf; ...@@ -31,7 +31,7 @@ using namespace caf;
namespace { namespace {
static constexpr auto task_timeout = std::chrono::seconds(10); constexpr auto task_timeout = std::chrono::seconds(10);
using plus_atom = atom_constant<atom("plus")>; using plus_atom = atom_constant<atom("plus")>;
using minus_atom = atom_constant<atom("minus")>; using minus_atom = atom_constant<atom("minus")>;
...@@ -97,7 +97,7 @@ void connecting(stateful_actor<state>*, ...@@ -97,7 +97,7 @@ void connecting(stateful_actor<state>*,
const std::string& host, uint16_t port); const std::string& host, uint16_t port);
// prototype definition for transition to `running` with Calculator // prototype definition for transition to `running` with Calculator
behavior running(stateful_actor<state>*, actor calculator); behavior running(stateful_actor<state>*, const actor& calculator);
// starting point of our FSM // starting point of our FSM
behavior init(stateful_actor<state>* self) { behavior init(stateful_actor<state>* self) {
...@@ -133,14 +133,15 @@ void connecting(stateful_actor<state>* self, ...@@ -133,14 +133,15 @@ void connecting(stateful_actor<state>* self,
// use request().await() to suspend regular behavior until MM responded // use request().await() to suspend regular behavior until MM responded
auto mm = self->system().middleman().actor_handle(); auto mm = self->system().middleman().actor_handle();
self->request(mm, infinite, connect_atom::value, host, port).await( self->request(mm, infinite, connect_atom::value, host, port).await(
[=](const node_id&, strong_actor_ptr serv, const std::set<std::string>& ifs) { [=](const node_id&, strong_actor_ptr serv,
const std::set<std::string>& ifs) {
if (!serv) { if (!serv) {
aout(self) << "*** no server found at \"" << host << "\":" aout(self) << R"(*** no server found at ")" << host << R"(":)"
<< port << endl; << port << endl;
return; return;
} }
if (!ifs.empty()) { if (!ifs.empty()) {
aout(self) << "*** typed actor found at \"" << host << "\":" aout(self) << R"(*** typed actor found at ")" << host << R"(":)"
<< port << ", but expected an untyped actor "<< endl; << port << ", but expected an untyped actor "<< endl;
return; return;
} }
...@@ -151,7 +152,7 @@ void connecting(stateful_actor<state>* self, ...@@ -151,7 +152,7 @@ void connecting(stateful_actor<state>* self,
self->become(running(self, hdl)); self->become(running(self, hdl));
}, },
[=](const error& err) { [=](const error& err) {
aout(self) << "*** cannot connect to \"" << host << "\":" aout(self) << R"(*** cannot connect to ")" << host << R"(":)"
<< port << " => " << self->system().render(err) << endl; << port << " => " << self->system().render(err) << endl;
self->become(unconnected(self)); self->become(unconnected(self));
} }
...@@ -159,7 +160,7 @@ void connecting(stateful_actor<state>* self, ...@@ -159,7 +160,7 @@ void connecting(stateful_actor<state>* self,
} }
// prototype definition for transition to `running` with Calculator // prototype definition for transition to `running` with Calculator
behavior running(stateful_actor<state>* self, actor calculator) { behavior running(stateful_actor<state>* self, const actor& calculator) {
auto send_task = [=](const task& x) { auto send_task = [=](const task& x) {
self->request(calculator, task_timeout, x.op, x.lhs, x.rhs).then( self->request(calculator, task_timeout, x.op, x.lhs, x.rhs).then(
[=](int result) { [=](int result) {
...@@ -192,7 +193,7 @@ behavior running(stateful_actor<state>* self, actor calculator) { ...@@ -192,7 +193,7 @@ behavior running(stateful_actor<state>* self, actor calculator) {
// removes leading and trailing whitespaces // removes leading and trailing whitespaces
string trim(std::string s) { string trim(std::string s) {
auto not_space = [](char c) { return !isspace(c); }; auto not_space = [](char c) { return isspace(c) == 0; };
// trim left // trim left
s.erase(s.begin(), find_if(s.begin(), s.end(), not_space)); s.erase(s.begin(), find_if(s.begin(), s.end(), not_space));
// trim right // trim right
...@@ -249,7 +250,7 @@ void client_repl(actor_system& system, const config& cfg) { ...@@ -249,7 +250,7 @@ void client_repl(actor_system& system, const config& cfg) {
anon_send(client, connect_atom::value, cfg.host, cfg.port); anon_send(client, connect_atom::value, cfg.host, cfg.port);
else else
cout << "*** no server received via config, " cout << "*** no server received via config, "
<< "please use \"connect <host> <port>\" before using the calculator" << R"(please use "connect <host> <port>" before using the calculator)"
<< endl; << endl;
// defining the handler outside the loop is more efficient as it avoids // defining the handler outside the loop is more efficient as it avoids
// re-creating the same object over and over again // re-creating the same object over and over again
...@@ -265,9 +266,9 @@ void client_repl(actor_system& system, const config& cfg) { ...@@ -265,9 +266,9 @@ void client_repl(actor_system& system, const config& cfg) {
char* end = nullptr; char* end = nullptr;
auto lport = strtoul(arg2.c_str(), &end, 10); auto lport = strtoul(arg2.c_str(), &end, 10);
if (end != arg2.c_str() + arg2.size()) if (end != arg2.c_str() + arg2.size())
cout << "\"" << arg2 << "\" is not an unsigned integer" << endl; cout << R"(")" << arg2 << R"(" is not an unsigned integer)" << endl;
else if (lport > std::numeric_limits<uint16_t>::max()) else if (lport > std::numeric_limits<uint16_t>::max())
cout << "\"" << arg2 << "\" > " cout << R"(")" << arg2 << R"(" > )"
<< std::numeric_limits<uint16_t>::max() << endl; << std::numeric_limits<uint16_t>::max() << endl;
else else
anon_send(client, connect_atom::value, move(arg1), anon_send(client, connect_atom::value, move(arg1),
......
...@@ -42,7 +42,7 @@ behavior client(event_based_actor* self, const string& name) { ...@@ -42,7 +42,7 @@ behavior client(event_based_actor* self, const string& name) {
} }
}, },
[=](join_atom, const group& what) { [=](join_atom, const group& what) {
for (auto g : self->joined_groups()) { for (const auto& g : self->joined_groups()) {
cout << "*** leave " << to_string(g) << endl; cout << "*** leave " << to_string(g) << endl;
self->send(g, name + " has left the chatroom"); self->send(g, name + " has left the chatroom");
self->leave(g); self->leave(g);
...@@ -108,7 +108,7 @@ void run_client(actor_system& system, const config& cfg) { ...@@ -108,7 +108,7 @@ void run_client(actor_system& system, const config& cfg) {
if (tmp) if (tmp)
anon_send(client_actor, join_atom::value, std::move(*tmp)); anon_send(client_actor, join_atom::value, std::move(*tmp));
else else
cerr << "*** failed to parse \"" << uri << "\" as group URI: " cerr << R"(*** failed to parse ")" << uri << R"(" as group URI: )"
<< system.render(tmp.error()) << endl; << system.render(tmp.error()) << endl;
} }
istream_iterator<line> eof; istream_iterator<line> eof;
......
...@@ -51,7 +51,7 @@ calculator::behavior_type calculator_fun(calculator::pointer self) { ...@@ -51,7 +51,7 @@ calculator::behavior_type calculator_fun(calculator::pointer self) {
// removes leading and trailing whitespaces // removes leading and trailing whitespaces
string trim(string s) { string trim(string s) {
auto not_space = [](char c) { return !isspace(c); }; auto not_space = [](char c) { return isspace(c) == 0; };
// trim left // trim left
s.erase(s.begin(), find_if(s.begin(), s.end(), not_space)); s.erase(s.begin(), find_if(s.begin(), s.end(), not_space));
// trim right // trim right
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
actor_control_block* ctrl() const; actor_control_block* ctrl() const;
virtual ~abstract_actor(); ~abstract_actor() override;
/// Cleans up any remaining state before the destructor is called. /// Cleans up any remaining state before the destructor is called.
/// This function makes sure it is safe to call virtual functions /// This function makes sure it is safe to call virtual functions
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
virtual void on_destroy(); virtual void on_destroy();
void enqueue(strong_actor_ptr sender, message_id mid, void enqueue(strong_actor_ptr sender, message_id mid,
message content, execution_unit* host) override; message msg, execution_unit* host) override;
/// Enqueues a new message wrapped in a `mailbox_element` to the actor. /// Enqueues a new message wrapped in a `mailbox_element` to the actor.
/// This `enqueue` variant allows to define forwarding chains. /// This `enqueue` variant allows to define forwarding chains.
......
...@@ -80,7 +80,7 @@ protected: ...@@ -80,7 +80,7 @@ protected:
private: private:
// can only be called from abstract_actor and abstract_group // can only be called from abstract_actor and abstract_group
abstract_channel(int init_flags); abstract_channel(int fs);
// Accumulates several state and type flags. Subtypes may use only the // Accumulates several state and type flags. Subtypes may use only the
// first 20 bits, i.e., the bitmask 0xFFF00000 is reserved for // first 20 bits, i.e., the bitmask 0xFFF00000 is reserved for
......
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
~abstract_group(); ~abstract_group() override;
// -- pure virtual member functions ------------------------------------------ // -- pure virtual member functions ------------------------------------------
...@@ -78,7 +78,7 @@ public: ...@@ -78,7 +78,7 @@ public:
} }
protected: protected:
abstract_group(group_module& parent, std::string id, node_id origin); abstract_group(group_module& mod, std::string id, node_id nid);
actor_system& system_; actor_system& system_;
group_module& parent_; group_module& parent_;
......
...@@ -73,14 +73,14 @@ public: ...@@ -73,14 +73,14 @@ public:
actor_companion(actor_config& cfg); actor_companion(actor_config& cfg);
~actor_companion(); ~actor_companion() override;
// -- overridden functions --------------------------------------------------- // -- overridden functions ---------------------------------------------------
void enqueue(mailbox_element_ptr what, execution_unit* host) override; void enqueue(mailbox_element_ptr ptr, execution_unit* host) override;
void enqueue(strong_actor_ptr sender, message_id mid, message content, void enqueue(strong_actor_ptr src, message_id mid, message content,
execution_unit* host) override; execution_unit* eu) override;
void launch(execution_unit* eu, bool lazy, bool hide) override; void launch(execution_unit* eu, bool lazy, bool hide) override;
......
...@@ -47,7 +47,7 @@ template <class F, class T, class Bhvr, class R, class... Ts> ...@@ -47,7 +47,7 @@ template <class F, class T, class Bhvr, class R, class... Ts>
class fun_decorator<F, T, Bhvr, spawn_mode::function, class fun_decorator<F, T, Bhvr, spawn_mode::function,
R, detail::type_list<Ts...>> { R, detail::type_list<Ts...>> {
public: public:
fun_decorator(const F& f, T*) : f_(f) { fun_decorator(F f, T*) : f_(std::move(f)) {
// nop // nop
} }
...@@ -84,7 +84,7 @@ template <class F, class T, class Bhvr, class R, class... Ts> ...@@ -84,7 +84,7 @@ template <class F, class T, class Bhvr, class R, class... Ts>
class fun_decorator<F, T, Bhvr, spawn_mode::function_with_selfptr, class fun_decorator<F, T, Bhvr, spawn_mode::function_with_selfptr,
R, detail::type_list<T*, Ts...>> { R, detail::type_list<T*, Ts...>> {
public: public:
fun_decorator(const F& f, T* ptr) : f_(f), ptr_(ptr) { fun_decorator(F f, T* ptr) : f_(std::move(f)), ptr_(ptr) {
// nop // nop
} }
......
...@@ -60,11 +60,11 @@ public: ...@@ -60,11 +60,11 @@ public:
actor_ostream& flush(); actor_ostream& flush();
/// Redirects all further output from `self` to `file_name`. /// Redirects all further output from `self` to `file_name`.
static void redirect(abstract_actor* self, std::string file_name, int flags = 0); static void redirect(abstract_actor* self, std::string fn, int flags = 0);
/// Redirects all further output from any actor that did not /// Redirects all further output from any actor that did not
/// redirect its output to `fname`. /// redirect its output to `fname`.
static void redirect_all(actor_system& sys, std::string fname, int flags = 0); static void redirect_all(actor_system& sys, std::string fn, int flags = 0);
/// Writes `arg` to the buffer allocated for the calling actor. /// Writes `arg` to the buffer allocated for the calling actor.
inline actor_ostream& operator<<(const char* arg) { inline actor_ostream& operator<<(const char* arg) {
......
...@@ -90,16 +90,16 @@ public: ...@@ -90,16 +90,16 @@ public:
return impl{std::move(init), std::move(sf), std::move(jf)}; return impl{std::move(init), std::move(sf), std::move(jf)};
} }
~actor_pool(); ~actor_pool() override;
/// Returns an actor pool without workers using the dispatch policy `pol`. /// Returns an actor pool without workers using the dispatch policy `pol`.
static actor make(execution_unit* ptr, policy pol); static actor make(execution_unit* eu, policy pol);
/// 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 make(execution_unit* ptr, size_t n, factory fac, policy pol); static actor make(execution_unit* eu, size_t num_workers, const factory& fac, policy pol);
void enqueue(mailbox_element_ptr what, execution_unit* host) override; void enqueue(mailbox_element_ptr what, execution_unit* eu) override;
actor_pool(actor_config& cfg); actor_pool(actor_config& cfg);
...@@ -109,7 +109,7 @@ protected: ...@@ -109,7 +109,7 @@ protected:
private: private:
bool filter(upgrade_lock<detail::shared_spinlock>&, bool filter(upgrade_lock<detail::shared_spinlock>&,
const strong_actor_ptr& sender, message_id mid, const strong_actor_ptr& sender, message_id mid,
message_view& content, execution_unit* host); message_view& mv, execution_unit* eu);
// call without workers_mtx_ held // call without workers_mtx_ held
void quit(execution_unit* host); void quit(execution_unit* host);
......
...@@ -36,7 +36,7 @@ class actor_proxy : public monitorable_actor { ...@@ -36,7 +36,7 @@ class actor_proxy : public monitorable_actor {
public: public:
explicit actor_proxy(actor_config& cfg); explicit actor_proxy(actor_config& cfg);
~actor_proxy(); ~actor_proxy() override;
/// Establishes a local link state that's /// Establishes a local link state that's
/// not synchronized back to the remote instance. /// not synchronized back to the remote instance.
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
strong_actor_ptr get(actor_id key) const; strong_actor_ptr get(actor_id key) const;
/// Associates a local actor with its ID. /// Associates a local actor with its ID.
void put(actor_id key, strong_actor_ptr value); void put(actor_id key, strong_actor_ptr val);
/// Removes an actor from this registry, /// Removes an actor from this registry,
/// leaving `reason` for future reference. /// leaving `reason` for future reference.
......
...@@ -65,7 +65,7 @@ struct mpi_field_access { ...@@ -65,7 +65,7 @@ struct mpi_field_access {
if (nr != 0) if (nr != 0)
return *types.portable_name(nr, nullptr); return *types.portable_name(nr, nullptr);
auto ptr = types.portable_name(0, &typeid(T)); auto ptr = types.portable_name(0, &typeid(T));
if (ptr) if (ptr != nullptr)
return *ptr; return *ptr;
std::string result = "<invalid-type[typeid "; std::string result = "<invalid-type[typeid ";
result += typeid(T).name(); result += typeid(T).name();
......
...@@ -107,18 +107,18 @@ public: ...@@ -107,18 +107,18 @@ public:
/// Parses `args` as tuple of strings containing CLI options /// Parses `args` as tuple of strings containing CLI options
/// and `ini_stream` as INI formatted input stream. /// and `ini_stream` as INI formatted input stream.
actor_system_config& parse(message& args, std::istream& ini_stream); actor_system_config& parse(message& args, std::istream& ini);
/// Parses the CLI options `{argc, argv}` and /// Parses the CLI options `{argc, argv}` and
/// `ini_stream` as INI formatted input stream. /// `ini_stream` as INI formatted input stream.
actor_system_config& parse(int argc, char** argv, std::istream& ini_stream); actor_system_config& parse(int argc, char** argv, std::istream& ini);
/// Parses the CLI options `{argc, argv}` and /// Parses the CLI options `{argc, argv}` and
/// tries to open `config_file_name` as INI formatted config file. /// tries to open `config_file_name` as INI formatted config file.
/// The parsers tries to open `caf-application.ini` if `config_file_name` /// The parsers tries to open `caf-application.ini` if `config_file_name`
/// is `nullptr`. /// is `nullptr`.
actor_system_config& parse(int argc, char** argv, actor_system_config& parse(int argc, char** argv,
const char* config_file_name = nullptr); const char* ini_file_cstr = nullptr);
/// Allows other nodes to spawn actors created by `fun` /// Allows other nodes to spawn actors created by `fun`
/// dynamically by using `name` as identifier. /// dynamically by using `name` as identifier.
...@@ -166,8 +166,8 @@ public: ...@@ -166,8 +166,8 @@ public:
/// Enables the actor system to convert errors of this error category /// Enables the actor system to convert errors of this error category
/// to human-readable strings via `renderer`. /// to human-readable strings via `renderer`.
actor_system_config& add_error_category(atom_value category, actor_system_config& add_error_category(atom_value x,
error_renderer renderer); error_renderer y);
/// Enables the actor system to convert errors of this error category /// Enables the actor system to convert errors of this error category
/// to human-readable strings via `to_string(T)`. /// to human-readable strings via `to_string(T)`.
...@@ -232,7 +232,7 @@ public: ...@@ -232,7 +232,7 @@ public:
message args_remainder; message args_remainder;
/// Sets a config by using its INI name `config_name` to `config_value`. /// Sets a config by using its INI name `config_name` to `config_value`.
actor_system_config& set(const char* config_name, config_value config_value); actor_system_config& set(const char* cn, config_value cv);
// -- config parameters of the scheduler ------------------------------------- // -- config parameters of the scheduler -------------------------------------
atom_value scheduler_policy; atom_value scheduler_policy;
......
...@@ -36,7 +36,7 @@ enum class atom_value : uint64_t { ...@@ -36,7 +36,7 @@ enum class atom_value : uint64_t {
}; };
/// @relates atom_value /// @relates atom_value
std::string to_string(const atom_value& x); std::string to_string(const atom_value& what);
atom_value atom_from_string(const std::string& x); atom_value atom_from_string(const std::string& x);
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
/// Any value, used to identify attachable instances. /// Any value, used to identify attachable instances.
const void* ptr; const void* ptr;
token(size_t subtype, const void* ptr); token(size_t typenr, const void* vptr);
}; };
virtual ~attachable(); virtual ~attachable();
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
behavior& operator=(const behavior&) = default; behavior& operator=(const behavior&) = default;
/// Creates a behavior from `fun` without timeout. /// Creates a behavior from `fun` without timeout.
behavior(const message_handler& fun); behavior(const message_handler& mh);
/// The list of arguments can contain match expressions, message handlers, /// The list of arguments can contain match expressions, message handlers,
/// and up to one timeout (if set, the timeout has to be the last argument). /// and up to one timeout (if set, the timeout has to be the last argument).
......
...@@ -95,7 +95,7 @@ public: ...@@ -95,7 +95,7 @@ public:
/// Pseudo receive condition modeling a single receive. /// Pseudo receive condition modeling a single receive.
class accept_one_cond : public receive_cond { class accept_one_cond : public receive_cond {
public: public:
virtual ~accept_one_cond(); ~accept_one_cond() override;
bool post() override; bool post() override;
}; };
...@@ -177,9 +177,9 @@ public: ...@@ -177,9 +177,9 @@ public:
// -- constructors and destructors ------------------------------------------- // -- constructors and destructors -------------------------------------------
blocking_actor(actor_config& sys); blocking_actor(actor_config& cfg);
~blocking_actor(); ~blocking_actor() override;
// -- overridden functions of abstract_actor --------------------------------- // -- overridden functions of abstract_actor ---------------------------------
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
uint16_t, int32_t, uint32_t, int64_t, uint16_t, int32_t, uint32_t, int64_t,
uint64_t>; uint64_t>;
config_option(const char* category, const char* name, const char* explanation); config_option(const char* cat, const char* nm, const char* expl);
virtual ~config_option(); virtual ~config_option();
...@@ -141,8 +141,8 @@ protected: ...@@ -141,8 +141,8 @@ protected:
return true; return true;
} }
void report_type_error(size_t line, config_value& x, const char* expected, void report_type_error(size_t ln, config_value& x, const char* expected,
optional<std::ostream&> errors); optional<std::ostream&> out);
private: private:
const char* category_; const char* category_;
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
// non-system messages are processed and then forwarded; // non-system messages are processed and then forwarded;
// system messages are handled and consumed on the spot; // system messages are handled and consumed on the spot;
// in either case, the processing is done synchronously // in either case, the processing is done synchronously
void enqueue(mailbox_element_ptr what, execution_unit* host) override; void enqueue(mailbox_element_ptr what, execution_unit* context) override;
message_types_set message_types() const override; message_types_set message_types() const override;
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
// non-system messages are processed and then forwarded; // non-system messages are processed and then forwarded;
// system messages are handled and consumed on the spot; // system messages are handled and consumed on the spot;
// in either case, the processing is done synchronously // in either case, the processing is done synchronously
void enqueue(mailbox_element_ptr what, execution_unit* host) override; void enqueue(mailbox_element_ptr what, execution_unit* context) override;
message_types_set message_types() const override; message_types_set message_types() const override;
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
static constexpr size_t token_type = attachable::token::observer; static constexpr size_t token_type = attachable::token::observer;
}; };
void actor_exited(const error& fail_state, execution_unit* host) override; void actor_exited(const error& rsn, execution_unit* host) override;
bool matches(const token& what) override; bool matches(const token& what) override;
...@@ -72,7 +72,7 @@ public: ...@@ -72,7 +72,7 @@ public:
}; };
private: private:
default_attachable(actor_addr observed, actor_addr observer, observe_type ot); default_attachable(actor_addr observed, actor_addr observer, observe_type type);
actor_addr observed_; actor_addr observed_;
actor_addr observer_; actor_addr observer_;
observe_type type_; observe_type type_;
......
...@@ -40,7 +40,7 @@ namespace caf { ...@@ -40,7 +40,7 @@ namespace caf {
/// Technology-independent deserialization interface. /// Technology-independent deserialization interface.
class deserializer : public data_processor<deserializer> { class deserializer : public data_processor<deserializer> {
public: public:
~deserializer(); ~deserializer() override;
using super = data_processor<deserializer>; using super = data_processor<deserializer>;
...@@ -51,9 +51,9 @@ public: ...@@ -51,9 +51,9 @@ public:
using is_saving = std::false_type; using is_saving = std::false_type;
using is_loading = std::true_type; using is_loading = std::true_type;
explicit deserializer(actor_system& sys); explicit deserializer(actor_system& x);
explicit deserializer(execution_unit* ctx = nullptr); explicit deserializer(execution_unit* x = nullptr);
}; };
#ifndef CAF_NO_EXCEPTIONS #ifndef CAF_NO_EXCEPTIONS
......
...@@ -58,7 +58,7 @@ class behavior_impl : public ref_counted { ...@@ -58,7 +58,7 @@ class behavior_impl : public ref_counted {
public: public:
using pointer = intrusive_ptr<behavior_impl>; using pointer = intrusive_ptr<behavior_impl>;
~behavior_impl(); ~behavior_impl() override;
behavior_impl(duration tout = duration{}); behavior_impl(duration tout = duration{});
......
...@@ -31,7 +31,7 @@ class blocking_behavior { ...@@ -31,7 +31,7 @@ class blocking_behavior {
public: public:
behavior& nested; behavior& nested;
blocking_behavior(behavior& nested); blocking_behavior(behavior& x);
blocking_behavior(blocking_behavior&&) = default; blocking_behavior(blocking_behavior&&) = default;
virtual ~blocking_behavior(); virtual ~blocking_behavior();
......
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
// nop // nop
} }
~default_invoke_result_visitor() { ~default_invoke_result_visitor() override {
// nop // nop
} }
......
...@@ -126,7 +126,7 @@ public: ...@@ -126,7 +126,7 @@ public:
// acquires only one lock // acquires only one lock
void append(pointer value) { void append(pointer value) {
CAF_ASSERT(value != nullptr); CAF_ASSERT(value != nullptr);
node* tmp = new node(value); auto* tmp = new node(value);
lock_guard guard(tail_lock_); lock_guard guard(tail_lock_);
// publish & swing last forward // publish & swing last forward
tail_.load()->next = tmp; tail_.load()->next = tmp;
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
// acquires both locks // acquires both locks
void prepend(pointer value) { void prepend(pointer value) {
CAF_ASSERT(value != nullptr); CAF_ASSERT(value != nullptr);
node* tmp = new node(value); auto* tmp = new node(value);
node* first = nullptr; node* first = nullptr;
// acquire both locks since we might touch last_ too // acquire both locks since we might touch last_ too
lock_guard guard1(head_lock_); lock_guard guard1(head_lock_);
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
dynamic_message_data(const dynamic_message_data& other); dynamic_message_data(const dynamic_message_data& other);
~dynamic_message_data(); ~dynamic_message_data() override;
// -- overridden observers of message_data ----------------------------------- // -- overridden observers of message_data -----------------------------------
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
template <class InputIterator> template <class InputIterator>
void assign(InputIterator first, InputIterator last, void assign(InputIterator first, InputIterator last,
// dummy SFINAE argument // dummy SFINAE argument
typename std::iterator_traits<InputIterator>::pointer = 0) { typename std::iterator_traits<InputIterator>::pointer = nullptr) {
auto dist = std::distance(first, last); auto dist = std::distance(first, last);
CAF_ASSERT(dist >= 0); CAF_ASSERT(dist >= 0);
resize(static_cast<size_t>(dist)); resize(static_cast<size_t>(dist));
......
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
// nop // nop
} }
~storage() { ~storage() override {
// nop // nop
} }
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
message_data() = default; message_data() = default;
message_data(const message_data&) = default; message_data(const message_data&) = default;
~message_data(); ~message_data() override;
// -- pure virtual observers ------------------------------------------------- // -- pure virtual observers -------------------------------------------------
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
} }
inline const message_data& operator*() const noexcept { inline const message_data& operator*() const noexcept {
return *ptr_.get(); return *ptr_;
} }
inline explicit operator bool() const noexcept { inline explicit operator bool() const noexcept {
......
...@@ -44,8 +44,8 @@ struct parse_ini_t { ...@@ -44,8 +44,8 @@ struct parse_ini_t {
/// @param raw_data Input stream of INI formatted text. /// @param raw_data Input stream of INI formatted text.
/// @param errors Output stream for parser errors. /// @param errors Output stream for parser errors.
/// @param consumer Callback consuming generated key-value pairs. /// @param consumer Callback consuming generated key-value pairs.
void operator()(std::istream& raw_data, void operator()(std::istream& input,
config_consumer consumer, const config_consumer& consumer_fun,
opt_err errors = none) const; opt_err errors = none) const;
}; };
......
...@@ -111,8 +111,8 @@ public: ...@@ -111,8 +111,8 @@ public:
return; return;
actor_msg_vec xs; actor_msg_vec xs;
xs.reserve(workers.size()); xs.reserve(workers.size());
for (size_t i = 0; i < workers.size(); ++i) for (const auto & worker : workers)
xs.emplace_back(workers[i], 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 = sys.spawn<collector_t, lazy_init>(init_, sf_, jf_, std::move(xs)); auto hdl = sys.spawn<collector_t, lazy_init>(init_, sf_, jf_, std::move(xs));
......
...@@ -75,8 +75,8 @@ struct meta_elements<type_list<Ts...>> { ...@@ -75,8 +75,8 @@ struct meta_elements<type_list<Ts...>> {
} }
}; };
bool try_match(const type_erased_tuple& xs, const meta_element* pattern_begin, bool try_match(const type_erased_tuple& xs, const meta_element* iter,
size_t pattern_size); size_t ps);
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
......
...@@ -202,13 +202,13 @@ class is_forward_iterator { ...@@ -202,13 +202,13 @@ class is_forward_iterator {
template <class C> template <class C>
static bool sfinae(C& x, C& y, static bool sfinae(C& x, C& y,
// check for operator* // check for operator*
decay_t<decltype(*x)>* = 0, decay_t<decltype(*x)>* = nullptr,
// check for operator++ returning an iterator // check for operator++ returning an iterator
decay_t<decltype(x = ++y)>* = 0, decay_t<decltype(x = ++y)>* = nullptr,
// check for operator== // check for operator==
decay_t<decltype(x == y)>* = 0, decay_t<decltype(x == y)>* = nullptr,
// check for operator!= // check for operator!=
decay_t<decltype(x != y)>* = 0); decay_t<decltype(x != y)>* = nullptr);
static void sfinae(...); static void sfinae(...);
...@@ -226,9 +226,9 @@ class is_iterable { ...@@ -226,9 +226,9 @@ class is_iterable {
template <class C> template <class C>
static bool sfinae(C* cc, static bool sfinae(C* cc,
// check if 'C::begin()' returns a forward iterator // check if 'C::begin()' returns a forward iterator
enable_if_tt<is_forward_iterator<decltype(cc->begin())>>* = 0, enable_if_tt<is_forward_iterator<decltype(cc->begin())>>* = nullptr,
// check if begin() and end() both exist and are comparable // check if begin() and end() both exist and are comparable
decltype(cc->begin() != cc->end())* = 0); decltype(cc->begin() != cc->end())* = nullptr);
// SFNINAE default // SFNINAE default
static void sfinae(void*); static void sfinae(void*);
...@@ -271,7 +271,7 @@ template <class T, ...@@ -271,7 +271,7 @@ template <class T,
|| std::is_function<T>::value> || std::is_function<T>::value>
struct has_serialize { struct has_serialize {
template <class U> template <class U>
static auto test_serialize(caf::serializer* sink, U* x, const unsigned int y = 0) static auto test_serialize(caf::serializer* sink, U* x, unsigned int y = 0)
-> decltype(serialize(*sink, *x, y)); -> decltype(serialize(*sink, *x, y));
template <class U> template <class U>
...@@ -282,7 +282,7 @@ struct has_serialize { ...@@ -282,7 +282,7 @@ struct has_serialize {
static auto test_serialize(...) -> std::false_type; static auto test_serialize(...) -> std::false_type;
template <class U> template <class U>
static auto test_deserialize(caf::deserializer* source, U* x, const unsigned int y = 0) static auto test_deserialize(caf::deserializer* source, U* x, unsigned int y = 0)
-> decltype(serialize(*source, *x, y)); -> decltype(serialize(*source, *x, y));
template <class U> template <class U>
......
...@@ -111,8 +111,8 @@ public: ...@@ -111,8 +111,8 @@ public:
error(const error&); error(const error&);
error& operator=(const error&); error& operator=(const error&);
error(uint8_t code, atom_value category); error(uint8_t x, atom_value y);
error(uint8_t code, atom_value category, message msg); error(uint8_t x, atom_value y, message z);
template <class E, class = enable_if_has_make_error_t<E>> template <class E, class = enable_if_has_make_error_t<E>>
error(E error_value) : error(make_error(error_value)) { error(E error_value) : error(make_error(error_value)) {
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
int compare(const error&) const noexcept; int compare(const error&) const noexcept;
int compare(uint8_t code, atom_value category) const noexcept; int compare(uint8_t x, atom_value y) const noexcept;
// -- modifiers -------------------------------------------------------------- // -- modifiers --------------------------------------------------------------
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
private: private:
// -- inspection support ----------------------------------------------------- // -- inspection support -----------------------------------------------------
error apply(inspect_fun f); error apply(const inspect_fun& f);
// -- nested classes --------------------------------------------------------- // -- nested classes ---------------------------------------------------------
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
explicit event_based_actor(actor_config& cfg); explicit event_based_actor(actor_config& cfg);
~event_based_actor(); ~event_based_actor() override;
// -- overridden functions of local_actor ------------------------------------ // -- overridden functions of local_actor ------------------------------------
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
template <class U> template <class U>
expected(U x, expected(U x,
typename std::enable_if<std::is_convertible<U, T>::value>::type* = 0) typename std::enable_if<std::is_convertible<U, T>::value>::type* = nullptr)
: engaged_(true) { : engaged_(true) {
new (&value_) T(std::move(x)); new (&value_) T(std::move(x));
} }
...@@ -380,10 +380,7 @@ public: ...@@ -380,10 +380,7 @@ public:
// nop // nop
} }
expected& operator=(const expected& other) noexcept { expected& operator=(const expected& other) = default;
error_ = other.error_;
return *this;
}
expected& operator=(expected&& other) noexcept { expected& operator=(expected&& other) noexcept {
error_ = std::move(other.error_); error_ = std::move(other.error_);
......
...@@ -32,9 +32,9 @@ class forwarding_actor_proxy : public actor_proxy { ...@@ -32,9 +32,9 @@ class forwarding_actor_proxy : public actor_proxy {
public: public:
using forwarding_stack = std::vector<strong_actor_ptr>; using forwarding_stack = std::vector<strong_actor_ptr>;
forwarding_actor_proxy(actor_config& cfg, actor parent); forwarding_actor_proxy(actor_config& cfg, actor mgr);
~forwarding_actor_proxy(); ~forwarding_actor_proxy() override;
void enqueue(mailbox_element_ptr what, execution_unit* host) override; void enqueue(mailbox_element_ptr what, execution_unit* host) override;
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
void local_unlink_from(abstract_actor* other) override; void local_unlink_from(abstract_actor* other) override;
void kill_proxy(execution_unit* ctx, error reason) override; void kill_proxy(execution_unit* ctx, error rsn) override;
actor manager() const; actor manager() const;
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
private: private:
void forward_msg(strong_actor_ptr sender, message_id mid, message msg, void forward_msg(strong_actor_ptr sender, message_id mid, message msg,
const forwarding_stack* fwd_stack = nullptr); const forwarding_stack* fwd = nullptr);
mutable detail::shared_spinlock manager_mtx_; mutable detail::shared_spinlock manager_mtx_;
actor manager_; actor manager_;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <new> #include <new>
#include <functional> #include <functional>
#include <utility>
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/typed_actor.hpp" #include "caf/typed_actor.hpp"
...@@ -139,9 +140,9 @@ public: ...@@ -139,9 +140,9 @@ public:
// nop // nop
} }
function_view(const type& impl, duration rel_timeout = infinite) function_view(type impl, duration rel_timeout = infinite)
: timeout(rel_timeout), : timeout(rel_timeout),
impl_(impl) { impl_(std::move(impl)) {
new_self(impl_); new_self(impl_);
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
namespace caf { namespace caf {
struct invalid_group_t { struct invalid_group_t {
constexpr invalid_group_t() {} constexpr invalid_group_t() = default;
}; };
/// Identifies an invalid {@link group}. /// Identifies an invalid {@link group}.
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
group(abstract_group*); group(abstract_group*);
group(intrusive_ptr<abstract_group> ptr); group(intrusive_ptr<abstract_group> gptr);
inline explicit operator bool() const noexcept { inline explicit operator bool() const noexcept {
return static_cast<bool>(ptr_); return static_cast<bool>(ptr_);
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
/// Get a pointer to the group associated with /// Get a pointer to the group associated with
/// `identifier` from the module `local`. /// `identifier` from the module `local`.
/// @threadsafe /// @threadsafe
group get_local(const std::string& identifier) const; group get_local(const std::string& group_identifier) const;
/// Returns an anonymous group. /// Returns an anonymous group.
/// Each calls to this member function returns a new instance /// Each calls to this member function returns a new instance
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
group anonymous() const; group anonymous() const;
/// Returns the module named `name` if it exists, otherwise `none`. /// Returns the module named `name` if it exists, otherwise `none`.
optional<group_module&> get_module(const std::string& name) const; optional<group_module&> get_module(const std::string& x) const;
private: private:
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
......
...@@ -36,7 +36,7 @@ class group_module { ...@@ -36,7 +36,7 @@ class group_module {
public: public:
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
group_module(actor_system& sys, std::string module_name); group_module(actor_system& sys, std::string mname);
virtual ~group_module(); virtual ~group_module();
......
...@@ -99,9 +99,9 @@ public: ...@@ -99,9 +99,9 @@ public:
// -- constructors, destructors, and assignment operators -------------------- // -- constructors, destructors, and assignment operators --------------------
local_actor(actor_config& sys); local_actor(actor_config& cfg);
~local_actor(); ~local_actor() override;
void on_destroy() override; void on_destroy() override;
...@@ -113,7 +113,7 @@ public: ...@@ -113,7 +113,7 @@ public:
/// Requests a new timeout for `mid`. /// Requests a new timeout for `mid`.
/// @pre `mid.valid()` /// @pre `mid.valid()`
void request_response_timeout(const duration& dr, message_id mid); void request_response_timeout(const duration& d, message_id mid);
// -- spawn functions -------------------------------------------------------- // -- spawn functions --------------------------------------------------------
...@@ -178,7 +178,7 @@ public: ...@@ -178,7 +178,7 @@ public:
// -- sending asynchronous messages ------------------------------------------ // -- sending asynchronous messages ------------------------------------------
/// Sends an exit message to `dest`. /// Sends an exit message to `dest`.
void send_exit(const actor_addr& dest, error reason); void send_exit(const actor_addr& whom, error reason);
void send_exit(const strong_actor_ptr& dest, error reason); void send_exit(const strong_actor_ptr& dest, error reason);
...@@ -209,7 +209,7 @@ public: ...@@ -209,7 +209,7 @@ public:
/// @cond PRIVATE /// @cond PRIVATE
void monitor(abstract_actor* whom); void monitor(abstract_actor* ptr);
/// @endcond /// @endcond
...@@ -283,12 +283,12 @@ public: ...@@ -283,12 +283,12 @@ public:
/// Serializes the state of this actor to `sink`. This function is /// Serializes the state of this actor to `sink`. This function is
/// only called if this actor has set the `is_serializable` flag. /// only called if this actor has set the `is_serializable` flag.
/// The default implementation throws a `std::logic_error`. /// The default implementation throws a `std::logic_error`.
virtual error save_state(serializer& sink, const unsigned int version); virtual error save_state(serializer& sink, unsigned int version);
/// Deserializes the state of this actor from `source`. This function is /// Deserializes the state of this actor from `source`. This function is
/// only called if this actor has set the `is_serializable` flag. /// only called if this actor has set the `is_serializable` flag.
/// The default implementation throws a `std::logic_error`. /// The default implementation throws a `std::logic_error`.
virtual error load_state(deserializer& source, const unsigned int version); virtual error load_state(deserializer& source, unsigned int version);
/// Returns the currently defined fail state. If this reason is not /// Returns the currently defined fail state. If this reason is not
/// `none` then the actor will terminate with this error after executing /// `none` then the actor will terminate with this error after executing
...@@ -349,7 +349,7 @@ public: ...@@ -349,7 +349,7 @@ public:
virtual void initialize(); virtual void initialize();
bool cleanup(error&& reason, execution_unit* host) override; bool cleanup(error&& fail_state, execution_unit* host) override;
message_id new_request_id(message_priority mp); message_id new_request_id(message_priority mp);
...@@ -363,7 +363,7 @@ public: ...@@ -363,7 +363,7 @@ public:
bool has_next_message(); bool has_next_message();
/// Appends `x` to the cache for later consumption. /// Appends `x` to the cache for later consumption.
void push_to_cache(mailbox_element_ptr x); void push_to_cache(mailbox_element_ptr ptr);
protected: protected:
// -- member variables ------------------------------------------------------- // -- member variables -------------------------------------------------------
......
...@@ -141,10 +141,10 @@ public: ...@@ -141,10 +141,10 @@ public:
/// Writes an entry to the log file. /// Writes an entry to the log file.
void log(int level, const char* component, const std::string& class_name, void log(int level, const char* component, const std::string& class_name,
const char* function_name, const char* file_name, const char* function_name, const char* c_full_file_name,
int line_num, const std::string& msg); int line_num, const std::string& msg);
~logger(); ~logger() override;
/** @cond PRIVATE */ /** @cond PRIVATE */
...@@ -173,7 +173,7 @@ private: ...@@ -173,7 +173,7 @@ private:
void log_prefix(std::ostream& out, int level, const char* component, void log_prefix(std::ostream& out, int level, const char* component,
const std::string& class_name, const char* function_name, const std::string& class_name, const char* function_name,
const char* file_name, int line_num, const char* c_full_file_name, int line_num,
const std::thread::id& tid = std::this_thread::get_id()); const std::thread::id& tid = std::this_thread::get_id());
actor_system& system_; actor_system& system_;
......
...@@ -66,10 +66,10 @@ public: ...@@ -66,10 +66,10 @@ public:
mailbox_element(); mailbox_element();
mailbox_element(strong_actor_ptr&& sender, message_id id, mailbox_element(strong_actor_ptr&& x, message_id y,
forwarding_stack&& stages); forwarding_stack&& z);
virtual ~mailbox_element(); ~mailbox_element() override;
type_erased_tuple& content() override; type_erased_tuple& content() override;
...@@ -111,11 +111,11 @@ public: ...@@ -111,11 +111,11 @@ public:
// nop // nop
} }
type_erased_tuple& content() { type_erased_tuple& content() override {
return *this; return *this;
} }
message move_content_to_message() { message move_content_to_message() override {
message_factory f; message_factory f;
auto& xs = this->data(); auto& xs = this->data();
return detail::apply_moved_args(f, detail::get_indices(xs), xs); return detail::apply_moved_args(f, detail::get_indices(xs), xs);
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
skip skip
}; };
match_case(uint32_t token); match_case(uint32_t tt);
match_case(match_case&&) = default; match_case(match_case&&) = default;
match_case(const match_case&) = default; match_case(const match_case&) = default;
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
message(message&&) noexcept; message(message&&) noexcept;
message& operator=(message&&) noexcept; message& operator=(message&&) noexcept;
explicit message(const data_ptr& vals) noexcept; explicit message(data_ptr ptr) noexcept;
~message(); ~message();
...@@ -133,7 +133,7 @@ public: ...@@ -133,7 +133,7 @@ public:
message drop_right(size_t n) const; message drop_right(size_t n) const;
/// Creates a new message of size `n` starting at the element at position `p`. /// Creates a new message of size `n` starting at the element at position `p`.
message slice(size_t p, size_t n) const; message slice(size_t pos, size_t n) const;
/// Filters this message by applying slices of it to `handler` and returns /// Filters this message by applying slices of it to `handler` and returns
/// the remaining elements of this operation. Slices are generated in the /// the remaining elements of this operation. Slices are generated in the
...@@ -206,8 +206,8 @@ public: ...@@ -206,8 +206,8 @@ public:
/// used arguments, and the generated help text. /// used arguments, and the generated help text.
/// @throws std::invalid_argument if no name or more than one long name is set /// @throws std::invalid_argument if no name or more than one long name is set
cli_res extract_opts(std::vector<cli_arg> xs, cli_res extract_opts(std::vector<cli_arg> xs,
help_factory help_generator = nullptr, const help_factory& f = nullptr,
bool suppress_help = false) const; bool no_help = false) const;
// -- inline observers ------------------------------------------------------- // -- inline observers -------------------------------------------------------
...@@ -328,7 +328,7 @@ private: ...@@ -328,7 +328,7 @@ private:
message extract_impl(size_t start, message_handler handler) const; message extract_impl(size_t start, message_handler handler) const;
static message concat_impl(std::initializer_list<data_ptr> ptrs); static message concat_impl(std::initializer_list<data_ptr> xs);
data_ptr vals_; data_ptr vals_;
}; };
...@@ -337,7 +337,7 @@ private: ...@@ -337,7 +337,7 @@ private:
error inspect(serializer& sink, message& msg); error inspect(serializer& sink, message& msg);
/// @relates message /// @relates message
error inspect(deserializer& sink, message& msg); error inspect(deserializer& source, message& msg);
/// @relates message /// @relates message
std::string to_string(const message& msg); std::string to_string(const message& msg);
...@@ -364,23 +364,23 @@ struct message::cli_arg { ...@@ -364,23 +364,23 @@ struct message::cli_arg {
bool* flag; bool* flag;
/// Creates a CLI argument without data. /// Creates a CLI argument without data.
cli_arg(std::string name, std::string text); cli_arg(std::string nstr, std::string tstr);
/// Creates a CLI flag option. The `flag` is set to `true` if the option /// Creates a CLI flag option. The `flag` is set to `true` if the option
/// was set, otherwise it is `false`. /// was set, otherwise it is `false`.
cli_arg(std::string name, std::string text, bool& flag); cli_arg(std::string nstr, std::string tstr, bool& arg);
/// Creates a CLI argument storing its matched argument in `dest`. /// Creates a CLI argument storing its matched argument in `dest`.
cli_arg(std::string name, std::string text, atom_value& dest); cli_arg(std::string nstr, std::string tstr, atom_value& arg);
/// Creates a CLI argument storing its matched argument in `dest`. /// Creates a CLI argument storing its matched argument in `dest`.
cli_arg(std::string name, std::string text, std::string& dest); cli_arg(std::string nstr, std::string tstr, std::string& arg);
/// Creates a CLI argument appending matched arguments to `dest`. /// Creates a CLI argument appending matched arguments to `dest`.
cli_arg(std::string name, std::string text, std::vector<std::string>& dest); cli_arg(std::string nstr, std::string tstr, std::vector<std::string>& arg);
/// Creates a CLI argument using the function object `f`. /// Creates a CLI argument using the function object `f`.
cli_arg(std::string name, std::string text, consumer f); cli_arg(std::string nstr, std::string tstr, consumer f);
/// Creates a CLI argument for converting from strings, /// Creates a CLI argument for converting from strings,
/// storing its matched argument in `dest`. /// storing its matched argument in `dest`.
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
/// @copydoc message::extract /// @copydoc message::extract
inline message extract(message_handler f) const { inline message extract(message_handler f) const {
return to_message().extract(f); return to_message().extract(std::move(f));
} }
/// @copydoc message::extract_opts /// @copydoc message::extract_opts
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
} }
/// Equal to `*this = other`. /// Equal to `*this = other`.
void assign(message_handler other); void assign(message_handler what);
/// Runs this handler and returns its (optional) result. /// Runs this handler and returns its (optional) result.
inline optional<message> operator()(message& arg) { inline optional<message> operator()(message& arg) {
......
...@@ -115,15 +115,15 @@ protected: ...@@ -115,15 +115,15 @@ protected:
* here be dragons: end of public interface * * here be dragons: end of public interface *
****************************************************************************/ ****************************************************************************/
bool link_impl(linking_operation op, abstract_actor* x) override; bool link_impl(linking_operation op, abstract_actor* other) override;
bool establish_link_impl(abstract_actor* other); bool establish_link_impl(abstract_actor* x);
bool remove_link_impl(abstract_actor* other); bool remove_link_impl(abstract_actor* x);
bool establish_backlink_impl(abstract_actor* other); bool establish_backlink_impl(abstract_actor* x);
bool remove_backlink_impl(abstract_actor* other); bool remove_backlink_impl(abstract_actor* x);
// precondition: `mtx_` is acquired // precondition: `mtx_` is acquired
inline void attach_impl(attachable_ptr& ptr) { inline void attach_impl(attachable_ptr& ptr) {
...@@ -134,12 +134,12 @@ protected: ...@@ -134,12 +134,12 @@ protected:
// precondition: `mtx_` is acquired // precondition: `mtx_` is acquired
static size_t detach_impl(const attachable::token& what, static size_t detach_impl(const attachable::token& what,
attachable_ptr& ptr, attachable_ptr& ptr,
bool stop_on_first_hit = false, bool stop_on_hit = false,
bool dry_run = false); bool dry_run = false);
// handles only `exit_msg` and `sys_atom` messages; // handles only `exit_msg` and `sys_atom` messages;
// returns true if the message is handled // returns true if the message is handled
bool handle_system_message(mailbox_element& node, execution_unit* context, bool handle_system_message(mailbox_element& x, execution_unit* ctx,
bool trap_exit); bool trap_exit);
// handles `exit_msg`, `sys_atom` messages, and additionally `down_msg` // handles `exit_msg`, `sys_atom` messages, and additionally `down_msg`
......
...@@ -35,7 +35,7 @@ struct named_actor_config { ...@@ -35,7 +35,7 @@ struct named_actor_config {
}; };
template <class Processor> template <class Processor>
void serialize(Processor& proc, named_actor_config& x, const unsigned int) { void serialize(Processor& proc, named_actor_config& x, unsigned int) {
proc & x.strategy; proc & x.strategy;
proc & x.low_watermark; proc & x.low_watermark;
proc & x.max_pending; proc & x.max_pending;
......
...@@ -71,12 +71,12 @@ public: ...@@ -71,12 +71,12 @@ public:
/// Creates a node ID from `process_id` and `hash`. /// Creates a node ID from `process_id` and `hash`.
/// @param process_id System-wide unique process identifier. /// @param process_id System-wide unique process identifier.
/// @param hash Unique node id as hexadecimal string representation. /// @param hash Unique node id as hexadecimal string representation.
node_id(uint32_t process_id, const std::string& hash); node_id(uint32_t procid, const std::string& hash);
/// Creates a node ID from `process_id` and `hash`. /// Creates a node ID from `process_id` and `hash`.
/// @param process_id System-wide unique process identifier. /// @param process_id System-wide unique process identifier.
/// @param node_id Unique node id. /// @param node_id Unique node id.
node_id(uint32_t process_id, const host_id_type& node_id); node_id(uint32_t procid, const host_id_type& hid);
/// Identifies the running process. /// Identifies the running process.
/// @returns A system-wide unique process identifier. /// @returns A system-wide unique process identifier.
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
int compare(const node_id& other) const; int compare(const node_id& other) const;
~data(); ~data() override;
data(); data();
......
...@@ -43,7 +43,7 @@ struct profiled : Policy { ...@@ -43,7 +43,7 @@ struct profiled : Policy {
static actor_id id_of(resumable* job) { static actor_id id_of(resumable* job) {
auto ptr = dynamic_cast<abstract_actor*>(job); auto ptr = dynamic_cast<abstract_actor*>(job);
return ptr ? ptr->id() : 0; return ptr != nullptr ? ptr->id() : 0;
} }
template <class Worker> template <class Worker>
......
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
// A thread-safe queue implementation. // A thread-safe queue implementation.
using queue_type = std::list<resumable*>; using queue_type = std::list<resumable*>;
~work_sharing(); ~work_sharing() override;
struct coordinator_data { struct coordinator_data {
inline explicit coordinator_data(scheduler::abstract_coordinator*) { inline explicit coordinator_data(scheduler::abstract_coordinator*) {
......
...@@ -40,7 +40,7 @@ namespace policy { ...@@ -40,7 +40,7 @@ namespace policy {
/// @extends scheduler_policy /// @extends scheduler_policy
class work_stealing : public unprofiled { class work_stealing : public unprofiled {
public: public:
~work_stealing(); ~work_stealing() override;
// A thread-safe queue implementation. // A thread-safe queue implementation.
using queue_type = detail::double_ended_queue<resumable>; using queue_type = detail::double_ended_queue<resumable>;
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
virtual execution_unit* registry_context() = 0; virtual execution_unit* registry_context() = 0;
}; };
proxy_registry(actor_system& sys, backend& mgm); proxy_registry(actor_system& sys, backend& be);
proxy_registry(const proxy_registry&) = delete; proxy_registry(const proxy_registry&) = delete;
proxy_registry& operator=(const proxy_registry&) = delete; proxy_registry& operator=(const proxy_registry&) = delete;
...@@ -80,16 +80,16 @@ public: ...@@ -80,16 +80,16 @@ public:
/// Returns the proxy instance identified by `node` and `aid` /// Returns the proxy instance identified by `node` and `aid`
/// or creates a new (default) proxy instance. /// or creates a new (default) proxy instance.
strong_actor_ptr get_or_put(const key_type& node, actor_id aid); strong_actor_ptr get_or_put(const key_type& nid, actor_id aid);
/// Returns all known proxies. /// Returns all known proxies.
std::vector<strong_actor_ptr> get_all(const key_type& node); std::vector<strong_actor_ptr> get_all(const key_type& node);
/// Deletes all proxies for `node`. /// Deletes all proxies for `node`.
void erase(const key_type& node); void erase(const key_type& nid);
/// Deletes the proxy with id `aid` for `node`. /// Deletes the proxy with id `aid` for `node`.
void erase(const key_type& node, actor_id aid, void erase(const key_type& inf, actor_id aid,
error rsn = exit_reason::remote_link_unreachable); error rsn = exit_reason::remote_link_unreachable);
/// Queries whether there are any proxies left. /// Queries whether there are any proxies left.
......
...@@ -33,7 +33,7 @@ namespace caf { ...@@ -33,7 +33,7 @@ namespace caf {
/// @relates intrusive_ptr /// @relates intrusive_ptr
class ref_counted : public memory_managed { class ref_counted : public memory_managed {
public: public:
~ref_counted(); ~ref_counted() override;
ref_counted(); ref_counted();
ref_counted(const ref_counted&); ref_counted(const ref_counted&);
......
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
} }
private: private:
response_promise deliver_impl(message response_message); response_promise deliver_impl(message msg);
execution_unit* ctx_; execution_unit* ctx_;
strong_actor_ptr self_; strong_actor_ptr self_;
......
...@@ -140,7 +140,7 @@ public: ...@@ -140,7 +140,7 @@ public:
explicit scheduled_actor(actor_config& cfg); explicit scheduled_actor(actor_config& cfg);
~scheduled_actor(); ~scheduled_actor() override;
// -- overridden functions of abstract_actor --------------------------------- // -- overridden functions of abstract_actor ---------------------------------
...@@ -191,7 +191,7 @@ public: ...@@ -191,7 +191,7 @@ public:
/// @warning This member function throws immediately in thread-based actors /// @warning This member function throws immediately in thread-based actors
/// that do not use the behavior stack, i.e., actors that use /// that do not use the behavior stack, i.e., actors that use
/// blocking API calls such as {@link receive()}. /// blocking API calls such as {@link receive()}.
void quit(error reason = error{}); void quit(error x = error{});
// -- event handlers --------------------------------------------------------- // -- event handlers ---------------------------------------------------------
...@@ -296,7 +296,7 @@ public: ...@@ -296,7 +296,7 @@ public:
void reset_timeout(uint32_t timeout_id); void reset_timeout(uint32_t timeout_id);
/// Returns whether `timeout_id` is currently active. /// Returns whether `timeout_id` is currently active.
bool is_active_timeout(uint32_t timeout_id) const; bool is_active_timeout(uint32_t tid) const;
// -- message processing ----------------------------------------------------- // -- message processing -----------------------------------------------------
......
...@@ -183,9 +183,9 @@ public: ...@@ -183,9 +183,9 @@ public:
super::init(cfg); super::init(cfg);
file_.open(cfg.scheduler_profiling_output_file); file_.open(cfg.scheduler_profiling_output_file);
if (!file_) if (!file_)
std::cerr << "[WARNING] could not open file \"" std::cerr << R"([WARNING] could not open file ")"
<< cfg.scheduler_profiling_output_file << cfg.scheduler_profiling_output_file
<< "\" (no profiler output will be generated)" << R"(" (no profiler output will be generated))"
<< std::endl; << std::endl;
resolution_ = msec{cfg.scheduler_profiling_ms_resolution}; resolution_ = msec{cfg.scheduler_profiling_ms_resolution};
} }
......
...@@ -90,9 +90,9 @@ public: ...@@ -90,9 +90,9 @@ public:
} }
actor_id id_of(resumable* ptr) { actor_id id_of(resumable* ptr) {
abstract_actor* dptr = ptr ? dynamic_cast<abstract_actor*>(ptr) abstract_actor* dptr = ptr != nullptr ? dynamic_cast<abstract_actor*>(ptr)
: nullptr; : nullptr;
return dptr ? dptr->id() : 0; return dptr != nullptr ? dptr->id() : 0;
} }
policy_data& data() { policy_data& data() {
......
...@@ -42,13 +42,13 @@ public: ...@@ -42,13 +42,13 @@ public:
// tell actor_cast which semantic this type uses // tell actor_cast which semantic this type uses
static constexpr bool has_weak_ptr_semantics = false; static constexpr bool has_weak_ptr_semantics = false;
scoped_actor(actor_system& sys, bool hide_actor = false); scoped_actor(actor_system& sys, bool hide = false);
scoped_actor(const scoped_actor&) = delete; scoped_actor(const scoped_actor&) = delete;
scoped_actor& operator=(const scoped_actor&) = delete; scoped_actor& operator=(const scoped_actor&) = delete;
scoped_actor(scoped_actor&&) = default; scoped_actor(scoped_actor&&) = delete;
scoped_actor& operator=(scoped_actor&&) = default; scoped_actor& operator=(scoped_actor&&) = delete;
~scoped_actor(); ~scoped_actor();
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
explicit serializer(execution_unit* ctx = nullptr); explicit serializer(execution_unit* ctx = nullptr);
virtual ~serializer(); ~serializer() override;
}; };
#ifndef CAF_NO_EXCEPTIONS #ifndef CAF_NO_EXCEPTIONS
......
...@@ -48,7 +48,7 @@ public: ...@@ -48,7 +48,7 @@ public:
this->setf(Base::is_serializable_flag); this->setf(Base::is_serializable_flag);
} }
~stateful_actor() { ~stateful_actor() override {
// nop // nop
} }
...@@ -63,11 +63,11 @@ public: ...@@ -63,11 +63,11 @@ public:
return get_name(state_); return get_name(state_);
} }
error save_state(serializer& sink, const unsigned int version) override { error save_state(serializer& sink, unsigned int version) override {
return serialize_state(&sink, state, version); return serialize_state(&sink, state, version);
} }
error load_state(deserializer& source, const unsigned int version) override { error load_state(deserializer& source, unsigned int version) override {
return serialize_state(&source, state, version); return serialize_state(&source, state, version);
} }
...@@ -85,13 +85,13 @@ public: ...@@ -85,13 +85,13 @@ public:
private: private:
template <class Inspector, class T> template <class Inspector, class T>
auto serialize_state(Inspector* f, T& x, const unsigned int) auto serialize_state(Inspector* f, T& x, unsigned int)
-> decltype(inspect(*f, x)) { -> decltype(inspect(*f, x)) {
return inspect(*f, x); return inspect(*f, x);
} }
template <class T> template <class T>
error serialize_state(void*, T&, const unsigned int) { error serialize_state(void*, T&, unsigned int) {
return sec::invalid_argument; return sec::invalid_argument;
} }
......
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
/// Checks whether the type of the stored value at position `pos` /// Checks whether the type of the stored value at position `pos`
/// matches type number `n` and run-time type information `p`. /// matches type number `n` and run-time type information `p`.
bool matches(size_t pos, uint16_t n, const std::type_info* p) const noexcept; bool matches(size_t pos, uint16_t nr, const std::type_info* ptr) const noexcept;
// -- convenience functions -------------------------------------------------- // -- convenience functions --------------------------------------------------
...@@ -236,7 +236,7 @@ class empty_type_erased_tuple : public type_erased_tuple { ...@@ -236,7 +236,7 @@ class empty_type_erased_tuple : public type_erased_tuple {
public: public:
empty_type_erased_tuple() = default; empty_type_erased_tuple() = default;
~empty_type_erased_tuple(); ~empty_type_erased_tuple() override;
void* get_mutable(size_t pos) override; void* get_mutable(size_t pos) override;
......
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
/// Checks whether the type of the stored value matches /// Checks whether the type of the stored value matches
/// the type nr and type info object. /// the type nr and type info object.
bool matches(uint16_t tnr, const std::type_info* tinf) const; bool matches(uint16_t nr, const std::type_info* ptr) const;
// -- convenience functions -------------------------------------------------- // -- convenience functions --------------------------------------------------
......
...@@ -71,9 +71,9 @@ public: ...@@ -71,9 +71,9 @@ public:
type_erased_value_ptr make_value(uint16_t nr) const; type_erased_value_ptr make_value(uint16_t nr) const;
type_erased_value_ptr make_value(const std::string& uniform_name) const; type_erased_value_ptr make_value(const std::string& x) const;
type_erased_value_ptr make_value(const std::type_info& ti) const; type_erased_value_ptr make_value(const std::type_info& x) const;
/// Returns the portable name for given type information or `nullptr` /// Returns the portable name for given type information or `nullptr`
/// if no mapping was found. /// if no mapping was found.
......
...@@ -57,7 +57,7 @@ static constexpr unit_t unit = unit_t{}; ...@@ -57,7 +57,7 @@ static constexpr unit_t unit = unit_t{};
/// @relates unit_t /// @relates unit_t
template <class Processor> template <class Processor>
void serialize(Processor&, const unit_t&, const unsigned int) { void serialize(Processor&, const unit_t&, unsigned int) {
// nop // nop
} }
......
...@@ -150,7 +150,7 @@ public: ...@@ -150,7 +150,7 @@ public:
} }
sink_handle(sink_cache* fc, iterator iter) : cache_(fc), iter_(iter) { sink_handle(sink_cache* fc, iterator iter) : cache_(fc), iter_(iter) {
if (cache_) if (cache_ != nullptr)
++iter_->second.first; ++iter_->second.first;
} }
...@@ -162,7 +162,7 @@ public: ...@@ -162,7 +162,7 @@ public:
if (cache_ != other.cache_ || iter_ != other.iter_) { if (cache_ != other.cache_ || iter_ != other.iter_) {
clear(); clear();
cache_ = other.cache_; cache_ = other.cache_;
if (cache_) { if (cache_ != nullptr) {
iter_ = other.iter_; iter_ = other.iter_;
++iter_->second.first; ++iter_->second.first;
} }
...@@ -185,7 +185,7 @@ public: ...@@ -185,7 +185,7 @@ public:
private: private:
void clear() { void clear() {
if (cache_ && --iter_->second.first == 0) { if (cache_ != nullptr && --iter_->second.first == 0) {
cache_->erase(iter_); cache_->erase(iter_);
cache_ = nullptr; cache_ = nullptr;
} }
...@@ -255,7 +255,7 @@ public: ...@@ -255,7 +255,7 @@ public:
return nullptr; return nullptr;
}; };
auto flush = [&](actor_data* what, bool forced) { auto flush = [&](actor_data* what, bool forced) {
if (!what) if (what == nullptr)
return; return;
auto& line = what->current_line; auto& line = what->current_line;
if (line.empty() || (line.back() != '\n' && !forced)) if (line.empty() || (line.back() != '\n' && !forced))
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
if (str.empty() || aid == invalid_actor_id) if (str.empty() || aid == invalid_actor_id)
return; return;
auto d = get_data(aid, true); auto d = get_data(aid, true);
if (d) { if (d != nullptr) {
d->current_line += str; d->current_line += str;
flush(d, false); flush(d, false);
} }
...@@ -284,7 +284,7 @@ public: ...@@ -284,7 +284,7 @@ public:
}, },
[&](delete_atom, actor_id aid) { [&](delete_atom, actor_id aid) {
auto data_ptr = get_data(aid, false); auto data_ptr = get_data(aid, false);
if (data_ptr) { if (data_ptr != nullptr) {
flush(data_ptr, true); flush(data_ptr, true);
data.erase(aid); data.erase(aid);
} }
...@@ -294,7 +294,7 @@ public: ...@@ -294,7 +294,7 @@ public:
}, },
[&](redirect_atom, actor_id aid, const std::string& fn, int flag) { [&](redirect_atom, actor_id aid, const std::string& fn, int flag) {
auto d = get_data(aid, true); auto d = get_data(aid, true);
if (d) if (d != nullptr)
d->redirect = get_sink_handle(system(), fcache, fn, flag); d->redirect = get_sink_handle(system(), fcache, fn, flag);
}, },
[&](exit_msg& em) { [&](exit_msg& em) {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "caf/actor.hpp" #include "caf/actor.hpp"
#include <cassert>
#include <utility> #include <utility>
#include "caf/actor_addr.hpp" #include "caf/actor_addr.hpp"
...@@ -85,11 +86,11 @@ actor operator*(actor f, actor g) { ...@@ -85,11 +86,11 @@ actor operator*(actor f, actor g) {
} }
actor actor::splice_impl(std::initializer_list<actor> xs) { actor actor::splice_impl(std::initializer_list<actor> xs) {
CAF_ASSERT(xs.size() >= 2); assert(xs.size() >= 2);
actor_system* sys = nullptr; actor_system* sys = nullptr;
std::vector<strong_actor_ptr> tmp; std::vector<strong_actor_ptr> tmp;
for (auto& x : xs) { for (auto& x : xs) {
if (!sys) if (sys == nullptr)
sys = &(x->home_system()); sys = &(x->home_system());
tmp.push_back(actor_cast<strong_actor_ptr>(x)); tmp.push_back(actor_cast<strong_actor_ptr>(x));
} }
......
...@@ -44,9 +44,9 @@ actor_addr::actor_addr(actor_control_block* ptr, bool add_ref) ...@@ -44,9 +44,9 @@ actor_addr::actor_addr(actor_control_block* ptr, bool add_ref)
intptr_t actor_addr::compare(const actor_control_block* lhs, intptr_t actor_addr::compare(const actor_control_block* lhs,
const actor_control_block* rhs) { const actor_control_block* rhs) {
// invalid actors are always "less" than valid actors // invalid actors are always "less" than valid actors
if (!lhs) if (lhs == nullptr)
return rhs ? -1 : 0; return rhs != nullptr ? -1 : 0;
if (!rhs) if (rhs == nullptr)
return 1; return 1;
// check for identity // check for identity
if (lhs == rhs) if (lhs == rhs)
......
...@@ -83,7 +83,7 @@ bool operator==(const abstract_actor* x, const strong_actor_ptr& y) { ...@@ -83,7 +83,7 @@ bool operator==(const abstract_actor* x, const strong_actor_ptr& y) {
error load_actor(strong_actor_ptr& storage, execution_unit* ctx, error load_actor(strong_actor_ptr& storage, execution_unit* ctx,
actor_id aid, const node_id& nid) { actor_id aid, const node_id& nid) {
if (!ctx) if (ctx == nullptr)
return sec::no_context; return sec::no_context;
auto& sys = ctx->system(); auto& sys = ctx->system();
if (sys.node() == nid) { if (sys.node() == nid) {
...@@ -93,7 +93,7 @@ error load_actor(strong_actor_ptr& storage, execution_unit* ctx, ...@@ -93,7 +93,7 @@ error load_actor(strong_actor_ptr& storage, execution_unit* ctx,
return none; return none;
} }
auto prp = ctx->proxy_registry_ptr(); auto prp = ctx->proxy_registry_ptr();
if (!prp) if (prp == nullptr)
return sec::no_proxy_registry; return sec::no_proxy_registry;
// deal with (proxies for) remote actors // deal with (proxies for) remote actors
storage = prp->get_or_put(nid, aid); storage = prp->get_or_put(nid, aid);
...@@ -102,7 +102,7 @@ error load_actor(strong_actor_ptr& storage, execution_unit* ctx, ...@@ -102,7 +102,7 @@ error load_actor(strong_actor_ptr& storage, execution_unit* ctx,
error save_actor(strong_actor_ptr& storage, execution_unit* ctx, error save_actor(strong_actor_ptr& storage, execution_unit* ctx,
actor_id aid, const node_id& nid) { actor_id aid, const node_id& nid) {
if (!ctx) if (ctx == nullptr)
return sec::no_context; return sec::no_context;
auto& sys = ctx->system(); auto& sys = ctx->system();
// register locally running actors to be able to deserialize them later // register locally running actors to be able to deserialize them later
...@@ -114,7 +114,7 @@ error save_actor(strong_actor_ptr& storage, execution_unit* ctx, ...@@ -114,7 +114,7 @@ error save_actor(strong_actor_ptr& storage, execution_unit* ctx,
namespace { namespace {
void append_to_string_impl(std::string& x, const actor_control_block* y) { void append_to_string_impl(std::string& x, const actor_control_block* y) {
if (y) { if (y != nullptr) {
x += std::to_string(y->aid); x += std::to_string(y->aid);
x += '@'; x += '@';
append_to_string(x, y->nid); append_to_string(x, y->nid);
......
...@@ -56,7 +56,7 @@ actor_ostream& actor_ostream::flush() { ...@@ -56,7 +56,7 @@ actor_ostream& actor_ostream::flush() {
} }
void actor_ostream::redirect(abstract_actor* self, std::string fn, int flags) { void actor_ostream::redirect(abstract_actor* self, std::string fn, int flags) {
if (!self) if (self == nullptr)
return; return;
auto pr = self->home_system().scheduler().printer(); auto pr = self->home_system().scheduler().printer();
pr->enqueue(make_mailbox_element(nullptr, message_id::make(), {}, pr->enqueue(make_mailbox_element(nullptr, message_id::make(), {},
......
...@@ -104,7 +104,7 @@ actor actor_pool::make(execution_unit* eu, policy pol) { ...@@ -104,7 +104,7 @@ actor actor_pool::make(execution_unit* eu, policy pol) {
} }
actor actor_pool::make(execution_unit* eu, size_t num_workers, actor actor_pool::make(execution_unit* eu, size_t num_workers,
factory fac, policy pol) { const factory& fac, policy pol) {
auto res = make(eu, std::move(pol)); auto res = make(eu, std::move(pol));
auto ptr = static_cast<actor_pool*>(actor_cast<abstract_actor*>(res)); auto ptr = static_cast<actor_pool*>(actor_cast<abstract_actor*>(res));
auto res_addr = ptr->address(); auto res_addr = ptr->address();
......
...@@ -47,7 +47,7 @@ struct kvstate { ...@@ -47,7 +47,7 @@ struct kvstate {
std::unordered_map<strong_actor_ptr, topic_set> subscribers; std::unordered_map<strong_actor_ptr, topic_set> subscribers;
static const char* name; static const char* name;
template <class Processor> template <class Processor>
friend void serialize(Processor& proc, kvstate& x, const unsigned int) { friend void serialize(Processor& proc, kvstate& x, unsigned int) {
proc & x.data; proc & x.data;
proc & x.subscribers; proc & x.subscribers;
} }
...@@ -345,7 +345,7 @@ bool actor_system::has_middleman() const { ...@@ -345,7 +345,7 @@ bool actor_system::has_middleman() const {
} }
io::middleman& actor_system::middleman() { io::middleman& actor_system::middleman() {
if (!middleman_) if (middleman_ == nullptr)
CAF_RAISE_ERROR("cannot access middleman: module not loaded"); CAF_RAISE_ERROR("cannot access middleman: module not loaded");
return *middleman_; return *middleman_;
} }
...@@ -355,7 +355,7 @@ bool actor_system::has_opencl_manager() const { ...@@ -355,7 +355,7 @@ bool actor_system::has_opencl_manager() const {
} }
opencl::manager& actor_system::opencl_manager() const { opencl::manager& actor_system::opencl_manager() const {
if (!opencl_manager_) if (opencl_manager_ == nullptr)
CAF_RAISE_ERROR("cannot access opencl manager: module not loaded"); CAF_RAISE_ERROR("cannot access opencl manager: module not loaded");
return *opencl_manager_; return *opencl_manager_;
} }
...@@ -414,7 +414,7 @@ actor_system::dyn_spawn_impl(const std::string& name, message& args, ...@@ -414,7 +414,7 @@ actor_system::dyn_spawn_impl(const std::string& name, message& args,
auto i = fs.find(name); auto i = fs.find(name);
if (i == fs.end()) if (i == fs.end())
return sec::unknown_type; return sec::unknown_type;
actor_config cfg{ctx ? ctx : &dummy_execution_unit_}; actor_config cfg{ctx != nullptr ? ctx : &dummy_execution_unit_};
auto res = i->second(cfg, args); auto res = i->second(cfg, args);
if (!res.first) if (!res.first)
return sec::cannot_spawn_actor_from_arguments; return sec::cannot_spawn_actor_from_arguments;
......
...@@ -49,13 +49,13 @@ public: ...@@ -49,13 +49,13 @@ public:
sinks_.emplace(x->full_name(), x->to_sink()); sinks_.emplace(x->full_name(), x->to_sink());
} }
void operator()(size_t ln, std::string name, config_value& cv) { void operator()(size_t ln, const std::string& name, config_value& cv) {
auto i = sinks_.find(name); auto i = sinks_.find(name);
if (i != sinks_.end()) if (i != sinks_.end())
(i->second)(ln, cv, none); (i->second)(ln, cv, none);
else else
std::cerr << "error in line " << ln std::cerr << "error in line " << ln
<< ": unrecognized parameter name \"" << name << "\""; << R"(: unrecognized parameter name ")" << name << R"(")";
} }
private: private:
...@@ -203,7 +203,7 @@ actor_system_config& actor_system_config::parse(int argc, char** argv, ...@@ -203,7 +203,7 @@ actor_system_config& actor_system_config::parse(int argc, char** argv,
if (argc > 1) if (argc > 1)
args = message_builder(argv + 1, argv + argc).move_to_message(); args = message_builder(argv + 1, argv + argc).move_to_message();
// set default config file name if not set by user // set default config file name if not set by user
if (!ini_file_cstr) if (ini_file_cstr == nullptr)
ini_file_cstr = "caf-application.ini"; ini_file_cstr = "caf-application.ini";
std::string config_file_name; std::string config_file_name;
// CLI file name has priority over default file name // CLI file name has priority over default file name
...@@ -261,12 +261,12 @@ actor_system_config& actor_system_config::parse(message& args, ...@@ -261,12 +261,12 @@ actor_system_config& actor_system_config::parse(message& args,
std::cerr << res.error << endl; std::cerr << res.error << endl;
return *this; return *this;
} }
if (res.opts.count("help")) { if (res.opts.count("help") != 0u) {
cli_helptext_printed = true; cli_helptext_printed = true;
cout << res.helptext << endl; cout << res.helptext << endl;
return *this; return *this;
} }
if (res.opts.count("caf#slave-mode")) { if (res.opts.count("caf#slave-mode") != 0u) {
slave_mode = true; slave_mode = true;
if (slave_name.empty()) if (slave_name.empty())
std::cerr << "running in slave mode but no name was configured" << endl; std::cerr << "running in slave mode but no name was configured" << endl;
...@@ -289,7 +289,7 @@ actor_system_config& actor_system_config::parse(message& args, ...@@ -289,7 +289,7 @@ actor_system_config& actor_system_config::parse(message& args,
}, middleman_network_backend, "middleman.network-backend"); }, middleman_network_backend, "middleman.network-backend");
verify_atom_opt({atom("stealing"), atom("sharing")}, verify_atom_opt({atom("stealing"), atom("sharing")},
scheduler_policy, "scheduler.policy "); scheduler_policy, "scheduler.policy ");
if (res.opts.count("caf#dump-config")) { if (res.opts.count("caf#dump-config") != 0u) {
cli_helptext_printed = true; cli_helptext_printed = true;
std::string category; std::string category;
option_vector* all_options[] = { &options_, &custom_options_ }; option_vector* all_options[] = { &options_, &custom_options_ };
...@@ -319,16 +319,13 @@ actor_system_config::add_error_category(atom_value x, error_renderer y) { ...@@ -319,16 +319,13 @@ actor_system_config::add_error_category(atom_value x, error_renderer y) {
} }
actor_system_config& actor_system_config::set(const char* cn, config_value cv) { actor_system_config& actor_system_config::set(const char* cn, config_value cv) {
std::string full_name; auto e = options_.end();
for (auto& x : options_) { auto i = std::find_if(options_.begin(), e, [cn](const option_ptr& ptr) {
// config_name has format "$category.$name" return ptr->full_name() == cn;
full_name = x->category(); });
full_name += '.'; if (i != e) {
full_name += x->name(); auto f = (*i)->to_sink();
if (full_name == cn) { f(0, cv, none);
auto f = x->to_sink();
f(0, cv, none);
}
} }
return *this; return *this;
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include <utility>
#include "caf/detail/behavior_impl.hpp" #include "caf/detail/behavior_impl.hpp"
#include "caf/message_handler.hpp" #include "caf/message_handler.hpp"
...@@ -45,9 +47,9 @@ public: ...@@ -45,9 +47,9 @@ public:
return new combinator(first, second->copy(tdef)); return new combinator(first, second->copy(tdef));
} }
combinator(const pointer& p0, const pointer& p1) combinator(pointer p0, const pointer& p1)
: behavior_impl(p1->timeout()), : behavior_impl(p1->timeout()),
first(p0), first(std::move(p0)),
second(p1) { second(p1) {
// nop // nop
} }
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include <utility>
#include "caf/blocking_actor.hpp" #include "caf/blocking_actor.hpp"
#include "caf/logger.hpp" #include "caf/logger.hpp"
...@@ -122,7 +124,7 @@ void blocking_actor::launch(execution_unit*, bool, bool hide) { ...@@ -122,7 +124,7 @@ void blocking_actor::launch(execution_unit*, bool, bool hide) {
blocking_actor::receive_while_helper blocking_actor::receive_while_helper
blocking_actor::receive_while(std::function<bool()> stmt) { blocking_actor::receive_while(std::function<bool()> stmt) {
return {this, stmt}; return {this, std::move(stmt)};
} }
blocking_actor::receive_while_helper blocking_actor::receive_while_helper
...@@ -277,7 +279,7 @@ public: ...@@ -277,7 +279,7 @@ public:
bool at_end() override { bool at_end() override {
if (ptr_->at_end()) { if (ptr_->at_end()) {
if (!fallback_) if (fallback_ == nullptr)
return true; return true;
ptr_ = fallback_; ptr_ = fallback_;
fallback_ = nullptr; fallback_ = nullptr;
......
...@@ -31,7 +31,7 @@ concatenated_tuple::concatenated_tuple(std::initializer_list<cow_ptr> xs) { ...@@ -31,7 +31,7 @@ concatenated_tuple::concatenated_tuple(std::initializer_list<cow_ptr> xs) {
for (auto& x : xs) { for (auto& x : xs) {
if (x) { if (x) {
auto dptr = dynamic_cast<const concatenated_tuple*>(x.get()); auto dptr = dynamic_cast<const concatenated_tuple*>(x.get());
if (dptr) { if (dptr != nullptr) {
auto& vec = dptr->data_; auto& vec = dptr->data_;
data_.insert(data_.end(), vec.begin(), vec.end()); data_.insert(data_.end(), vec.begin(), vec.end());
} else { } else {
......
...@@ -64,7 +64,7 @@ std::string config_option::full_name() const { ...@@ -64,7 +64,7 @@ std::string config_option::full_name() const {
res += '.'; res += '.';
auto name_begin = name(); auto name_begin = name();
const char* name_end = strchr(name(), ','); const char* name_end = strchr(name(), ',');
if (name_end) if (name_end != nullptr)
res.insert(res.end(), name_begin, name_end); res.insert(res.end(), name_begin, name_end);
else else
res += name(); res += name();
......
...@@ -32,20 +32,19 @@ decorated_tuple::decorated_tuple(cow_ptr&& d, vector_type&& v) ...@@ -32,20 +32,19 @@ decorated_tuple::decorated_tuple(cow_ptr&& d, vector_type&& v)
|| *(std::max_element(mapping_.begin(), mapping_.end())) || *(std::max_element(mapping_.begin(), mapping_.end()))
< static_cast<const cow_ptr&>(decorated_)->size()); < static_cast<const cow_ptr&>(decorated_)->size());
// calculate type token // calculate type token
for (size_t i = 0; i < mapping_.size(); ++i) { for (unsigned long i : mapping_) {
type_token_ <<= 6; type_token_ <<= 6;
type_token_ |= decorated_->type_nr(mapping_[i]); type_token_ |= decorated_->type_nr(i);
} }
} }
decorated_tuple::cow_ptr decorated_tuple::make(cow_ptr d, vector_type v) { decorated_tuple::cow_ptr decorated_tuple::make(cow_ptr d, vector_type v) {
auto ptr = dynamic_cast<const decorated_tuple*>(d.get()); auto ptr = dynamic_cast<const decorated_tuple*>(d.get());
if (ptr) { if (ptr != nullptr) {
d = ptr->decorated(); d = ptr->decorated();
auto& pmap = ptr->mapping(); auto& pmap = ptr->mapping();
for (size_t i = 0; i < v.size(); ++i) { for (auto& i : v)
v[i] = pmap[v[i]]; i = pmap[i];
}
} }
return make_counted<decorated_tuple>(std::move(d), std::move(v)); return make_counted<decorated_tuple>(std::move(d), std::move(v));
} }
......
...@@ -46,7 +46,7 @@ error::error(none_t) noexcept : data_(nullptr) { ...@@ -46,7 +46,7 @@ error::error(none_t) noexcept : data_(nullptr) {
} }
error::error(error&& x) noexcept : data_(x.data_) { error::error(error&& x) noexcept : data_(x.data_) {
if (data_) if (data_ != nullptr)
x.data_ = nullptr; x.data_ = nullptr;
} }
...@@ -61,7 +61,7 @@ error::error(const error& x) : data_(x ? new data(*x.data_) : nullptr) { ...@@ -61,7 +61,7 @@ error::error(const error& x) : data_(x ? new data(*x.data_) : nullptr) {
error& error::operator=(const error& x) { error& error::operator=(const error& x) {
if (x) { if (x) {
if (!data_) if (data_ == nullptr)
data_ = new data(*x.data_); data_ = new data(*x.data_);
else else
*data_ = *x.data_; *data_ = *x.data_;
...@@ -118,7 +118,7 @@ int error::compare(const error& x) const noexcept { ...@@ -118,7 +118,7 @@ int error::compare(const error& x) const noexcept {
int error::compare(uint8_t x, atom_value y) const noexcept { int error::compare(uint8_t x, atom_value y) const noexcept {
uint8_t mx; uint8_t mx;
atom_value my; atom_value my;
if (data_) { if (data_ != nullptr) {
mx = data_->code; mx = data_->code;
my = data_->category; my = data_->category;
} else { } else {
...@@ -143,7 +143,7 @@ message& error::context() noexcept { ...@@ -143,7 +143,7 @@ message& error::context() noexcept {
} }
void error::clear() noexcept { void error::clear() noexcept {
if (data_) { if (data_ != nullptr) {
delete data_; delete data_;
data_ = nullptr; data_ = nullptr;
} }
...@@ -151,9 +151,9 @@ void error::clear() noexcept { ...@@ -151,9 +151,9 @@ void error::clear() noexcept {
// -- inspection support ----------------------------------------------------- // -- inspection support -----------------------------------------------------
error error::apply(inspect_fun f) { error error::apply(const inspect_fun& f) {
data tmp{0, atom(""), message{}}; data tmp{0, atom(""), message{}};
data& ref = data_ ? *data_ : tmp; data& ref = data_ != nullptr ? *data_ : tmp;
auto result = f(meta::type_name("error"), ref.code, ref.category, auto result = f(meta::type_name("error"), ref.code, ref.category,
meta::omittable_if_empty(), ref.context); meta::omittable_if_empty(), ref.context);
if (ref.code == 0) if (ref.code == 0)
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#include <utility>
#include "caf/forwarding_actor_proxy.hpp" #include "caf/forwarding_actor_proxy.hpp"
#include "caf/send.hpp" #include "caf/send.hpp"
...@@ -28,7 +30,7 @@ namespace caf { ...@@ -28,7 +30,7 @@ namespace caf {
forwarding_actor_proxy::forwarding_actor_proxy(actor_config& cfg, actor mgr) forwarding_actor_proxy::forwarding_actor_proxy(actor_config& cfg, actor mgr)
: actor_proxy(cfg), : actor_proxy(cfg),
manager_(mgr) { manager_(std::move(mgr)) {
// nop // nop
} }
...@@ -57,7 +59,7 @@ void forwarding_actor_proxy::forward_msg(strong_actor_ptr sender, ...@@ -57,7 +59,7 @@ void forwarding_actor_proxy::forward_msg(strong_actor_ptr sender,
if (manager_) if (manager_)
manager_->enqueue(nullptr, invalid_message_id, manager_->enqueue(nullptr, invalid_message_id,
make_message(forward_atom::value, std::move(sender), make_message(forward_atom::value, std::move(sender),
fwd ? *fwd : tmp, fwd != nullptr ? *fwd : tmp,
strong_actor_ptr{ctrl()}, strong_actor_ptr{ctrl()},
mid, std::move(msg)), mid, std::move(msg)),
nullptr); nullptr);
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
#include <net/if_dl.h> #include <net/if_dl.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <cerrno>
#include <stdio.h> #include <cstdio>
#include <stdlib.h> #include <cstdlib>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
...@@ -66,7 +66,7 @@ std::vector<iface_info> get_mac_addresses() { ...@@ -66,7 +66,7 @@ std::vector<iface_info> get_mac_addresses() {
} }
auto addr = oss.str(); auto addr = oss.str();
if (addr != "00:00:00:00:00:00") { if (addr != "00:00:00:00:00:00") {
result.push_back({i->if_name, std::move(addr)}); result.emplace_back(i->if_name, std::move(addr));
} }
} }
if_freenameindex(indices); if_freenameindex(indices);
......
...@@ -50,7 +50,7 @@ std::string get_root_uuid() { ...@@ -50,7 +50,7 @@ std::string get_root_uuid() {
// fetch hd serial // fetch hd serial
std::string uuid; std::string uuid;
FILE* get_uuid_cmd = popen(s_get_uuid, "r"); FILE* get_uuid_cmd = popen(s_get_uuid, "r");
while (fgets(cbuf, 100, get_uuid_cmd) != 0) { while (fgets(cbuf, 100, get_uuid_cmd) != nullptr) {
uuid += cbuf; uuid += cbuf;
} }
pclose(get_uuid_cmd); pclose(get_uuid_cmd);
......
...@@ -58,7 +58,7 @@ intptr_t group::compare(const group& other) const noexcept { ...@@ -58,7 +58,7 @@ intptr_t group::compare(const group& other) const noexcept {
error inspect(serializer& f, group& x) { error inspect(serializer& f, group& x) {
std::string mod_name; std::string mod_name;
auto ptr = x.get(); auto ptr = x.get();
if (!ptr) if (ptr == nullptr)
return f(mod_name); return f(mod_name);
mod_name = ptr->module().name(); mod_name = ptr->module().name();
auto e = f(mod_name); auto e = f(mod_name);
...@@ -72,7 +72,7 @@ error inspect(deserializer& f, group& x) { ...@@ -72,7 +72,7 @@ error inspect(deserializer& f, group& x) {
x = invalid_group; x = invalid_group;
return none; return none;
} }
if (!f.context()) if (f.context() == nullptr)
return sec::no_context; return sec::no_context;
auto& sys = f.context()->system(); auto& sys = f.context()->system();
auto mod = sys.groups().get_module(module_name); auto mod = sys.groups().get_module(module_name);
......
...@@ -100,9 +100,7 @@ public: ...@@ -100,9 +100,7 @@ public:
bool subscribe(strong_actor_ptr who) override { bool subscribe(strong_actor_ptr who) override {
CAF_LOG_TRACE(CAF_ARG(who)); CAF_LOG_TRACE(CAF_ARG(who));
if (add_subscriber(std::move(who)).first) return add_subscriber(std::move(who)).first;
return true;
return false;
} }
void unsubscribe(const actor_control_block* who) override { void unsubscribe(const actor_control_block* who) override {
...@@ -122,9 +120,9 @@ public: ...@@ -122,9 +120,9 @@ public:
} }
local_group(local_group_module& mod, std::string id, node_id nid, local_group(local_group_module& mod, std::string id, node_id nid,
optional<actor> local_broker); optional<actor> lb);
~local_group(); ~local_group() override;
protected: protected:
detail::shared_spinlock mtx_; detail::shared_spinlock mtx_;
...@@ -224,9 +222,9 @@ public: ...@@ -224,9 +222,9 @@ public:
CAF_LOG_TRACE(""); CAF_LOG_TRACE("");
} }
behavior make_behavior(); behavior make_behavior() override;
void on_exit() { void on_exit() override {
group_.reset(); group_.reset();
} }
...@@ -487,9 +485,9 @@ expected<group> group_manager::get(const std::string& module_name, ...@@ -487,9 +485,9 @@ expected<group> group_manager::get(const std::string& module_name,
auto mod = get_module(module_name); auto mod = get_module(module_name);
if (mod) if (mod)
return mod->get(group_identifier); return mod->get(group_identifier);
std::string error_msg = "no module named \""; std::string error_msg = R"(no module named ")";
error_msg += module_name; error_msg += module_name;
error_msg += "\" found"; error_msg += R"(" found)";
return make_error(sec::no_such_group_module, std::move(error_msg)); return make_error(sec::no_such_group_module, std::move(error_msg));
} }
......
...@@ -71,7 +71,7 @@ void local_actor::request_response_timeout(const duration& d, message_id mid) { ...@@ -71,7 +71,7 @@ void local_actor::request_response_timeout(const duration& d, message_id mid) {
} }
void local_actor::monitor(abstract_actor* ptr) { void local_actor::monitor(abstract_actor* ptr) {
if (ptr) if (ptr != nullptr)
ptr->attach(default_attachable::make_monitor(ptr->address(), address())); ptr->attach(default_attachable::make_monitor(ptr->address(), address()));
} }
...@@ -110,7 +110,7 @@ mailbox_element_ptr local_actor::next_message() { ...@@ -110,7 +110,7 @@ mailbox_element_ptr local_actor::next_message() {
auto hp_pos = i; auto hp_pos = i;
// read whole mailbox at once // read whole mailbox at once
auto tmp = mailbox().try_pop(); auto tmp = mailbox().try_pop();
while (tmp) { while (tmp != nullptr) {
cache.insert(tmp->is_high_priority() ? hp_pos : e, tmp); cache.insert(tmp->is_high_priority() ? hp_pos : e, tmp);
// adjust high priority insert point on first low prio element insert // adjust high priority insert point on first low prio element insert
if (hp_pos == e && !tmp->is_high_priority()) if (hp_pos == e && !tmp->is_high_priority())
......
...@@ -141,7 +141,7 @@ void prettify_type_name(std::string& class_name, const char* c_class_name) { ...@@ -141,7 +141,7 @@ void prettify_type_name(std::string& class_name, const char* c_class_name) {
# if defined(CAF_LINUX) || defined(CAF_MACOS) # if defined(CAF_LINUX) || defined(CAF_MACOS)
int stat = 0; int stat = 0;
std::unique_ptr<char, decltype(free)*> real_class_name{nullptr, free}; std::unique_ptr<char, decltype(free)*> real_class_name{nullptr, free};
auto tmp = abi::__cxa_demangle(c_class_name, 0, 0, &stat); auto tmp = abi::__cxa_demangle(c_class_name, nullptr, nullptr, &stat);
real_class_name.reset(tmp); real_class_name.reset(tmp);
class_name = stat == 0 ? real_class_name.get() : c_class_name; class_name = stat == 0 ? real_class_name.get() : c_class_name;
# else # else
...@@ -288,7 +288,7 @@ void logger::log(int level, const char* component, ...@@ -288,7 +288,7 @@ void logger::log(int level, const char* component,
} }
void logger::set_current_actor_system(actor_system* x) { void logger::set_current_actor_system(actor_system* x) {
if (x) if (x != nullptr)
set_current_logger(&x->logger()); set_current_logger(&x->logger());
else else
set_current_logger(nullptr); set_current_logger(nullptr);
...@@ -303,7 +303,7 @@ void logger::log_static(int level, const char* component, ...@@ -303,7 +303,7 @@ void logger::log_static(int level, const char* component,
const char* function_name, const char* file_name, const char* function_name, const char* file_name,
int line_num, const std::string& msg) { int line_num, const std::string& msg) {
auto ptr = get_current_logger(); auto ptr = get_current_logger();
if (ptr) if (ptr != nullptr)
ptr->log(level, component, class_name, function_name, file_name, line_num, ptr->log(level, component, class_name, function_name, file_name, line_num,
msg); msg);
} }
......
...@@ -35,7 +35,7 @@ public: ...@@ -35,7 +35,7 @@ public:
type_erased_tuple& content() override { type_erased_tuple& content() override {
auto ptr = msg_.vals().raw_ptr(); auto ptr = msg_.vals().raw_ptr();
if (ptr) if (ptr != nullptr)
return *ptr; return *ptr;
return dummy_; return dummy_;
} }
......
...@@ -62,7 +62,7 @@ void make_cache_map() { ...@@ -62,7 +62,7 @@ void make_cache_map() {
cache_map& get_cache_map() { cache_map& get_cache_map() {
pthread_once(&s_key_once, make_cache_map); pthread_once(&s_key_once, make_cache_map);
auto cache = reinterpret_cast<cache_map*>(pthread_getspecific(s_key)); auto cache = reinterpret_cast<cache_map*>(pthread_getspecific(s_key));
if (!cache) { if (cache == nullptr) {
cache = new cache_map; cache = new cache_map;
pthread_setspecific(s_key, cache); pthread_setspecific(s_key, cache);
// insert default types // insert default types
......
...@@ -48,9 +48,8 @@ merged_tuple::merged_tuple(data_type xs, mapping_type ys) ...@@ -48,9 +48,8 @@ merged_tuple::merged_tuple(data_type xs, mapping_type ys)
CAF_ASSERT(!data_.empty()); CAF_ASSERT(!data_.empty());
CAF_ASSERT(!mapping_.empty()); CAF_ASSERT(!mapping_.empty());
// calculate type token // calculate type token
for (size_t i = 0; i < mapping_.size(); ++i) { for (auto& p : mapping_) {
type_token_ <<= 6; type_token_ <<= 6;
auto& p = mapping_[i];
type_token_ |= data_[p.first]->type_nr(p.second); type_token_ |= data_[p.first]->type_nr(p.second);
} }
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "caf/message.hpp" #include "caf/message.hpp"
#include <iostream> #include <iostream>
#include <utility>
#include <utility>
#include "caf/serializer.hpp" #include "caf/serializer.hpp"
#include "caf/actor_system.hpp" #include "caf/actor_system.hpp"
...@@ -42,7 +44,7 @@ message::message(message&& other) noexcept : vals_(std::move(other.vals_)) { ...@@ -42,7 +44,7 @@ message::message(message&& other) noexcept : vals_(std::move(other.vals_)) {
// nop // nop
} }
message::message(const data_ptr& ptr) noexcept : vals_(ptr) { message::message(data_ptr ptr) noexcept : vals_(std::move(ptr)) {
// nop // nop
} }
...@@ -144,11 +146,11 @@ message message::extract_impl(size_t start, message_handler handler) const { ...@@ -144,11 +146,11 @@ message message::extract_impl(size_t start, message_handler handler) const {
} }
message message::extract(message_handler handler) const { message message::extract(message_handler handler) const {
return extract_impl(0, handler); return extract_impl(0, std::move(handler));
} }
message::cli_res message::extract_opts(std::vector<cli_arg> xs, message::cli_res message::extract_opts(std::vector<cli_arg> xs,
help_factory f, bool no_help) const { const help_factory& f, bool no_help) const {
std::string helpstr; std::string helpstr;
auto make_error = [&](std::string err) -> cli_res { auto make_error = [&](std::string err) -> cli_res {
return {*this, std::set<std::string>{}, std::move(helpstr), std::move(err)}; return {*this, std::set<std::string>{}, std::move(helpstr), std::move(err)};
...@@ -166,7 +168,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs, ...@@ -166,7 +168,7 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs,
|| std::find_if(s.begin() + 1, s.end(), has_short_help) != s.end(); || std::find_if(s.begin() + 1, s.end(), has_short_help) != s.end();
}; };
if (!no_help && std::none_of(xs.begin(), xs.end(), pred)) { if (!no_help && std::none_of(xs.begin(), xs.end(), pred)) {
xs.push_back(cli_arg{"help,h,?", "print this text"}); xs.emplace_back("help,h,?", "print this text");
} }
std::map<std::string, cli_arg*> shorts; std::map<std::string, cli_arg*> shorts;
std::map<std::string, cli_arg*> longs; std::map<std::string, cli_arg*> longs;
...@@ -254,9 +256,9 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs, ...@@ -254,9 +256,9 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs,
} }
// no value given, try two-argument form below // no value given, try two-argument form below
return skip(); return skip();
} else if (i->second->flag) {
*i->second->flag = true;
} }
if (i->second->flag != nullptr)
*i->second->flag = true;
insert_opt_name(i->second); insert_opt_name(i->second);
return none; return none;
} }
...@@ -274,9 +276,9 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs, ...@@ -274,9 +276,9 @@ message::cli_res message::extract_opts(std::vector<cli_arg> xs,
} }
insert_opt_name(j->second); insert_opt_name(j->second);
return none; return none;
} else if (j->second->flag) {
*j->second->flag = true;
} }
if (j->second->flag != nullptr)
*j->second->flag = true;
insert_opt_name(j->second); insert_opt_name(j->second);
return none; return none;
} }
...@@ -383,7 +385,7 @@ message message::concat_impl(std::initializer_list<data_ptr> xs) { ...@@ -383,7 +385,7 @@ message message::concat_impl(std::initializer_list<data_ptr> xs) {
} }
error inspect(serializer& sink, message& msg) { error inspect(serializer& sink, message& msg) {
if (!sink.context()) if (sink.context() == nullptr)
return sec::no_context; return sec::no_context;
// build type name // build type name
uint16_t zero = 0; uint16_t zero = 0;
...@@ -396,13 +398,13 @@ error inspect(serializer& sink, message& msg) { ...@@ -396,13 +398,13 @@ error inspect(serializer& sink, message& msg) {
for (size_t i = 0; i < n; ++i) { for (size_t i = 0; i < n; ++i) {
auto rtti = msg.cvals()->type(i); auto rtti = msg.cvals()->type(i);
auto ptr = types.portable_name(rtti); auto ptr = types.portable_name(rtti);
if (!ptr) { if (ptr == nullptr) {
std::cerr << "[ERROR]: cannot serialize message because a type was " std::cerr << "[ERROR]: cannot serialize message because a type was "
"not added to the types list, typeid name: " "not added to the types list, typeid name: "
<< (rtti.second ? rtti.second->name() : "-not-available-") << (rtti.second != nullptr ? rtti.second->name() : "-not-available-")
<< std::endl; << std::endl;
return make_error(sec::unknown_type, return make_error(sec::unknown_type,
rtti.second ? rtti.second->name() : "-not-available-"); rtti.second != nullptr ? rtti.second->name() : "-not-available-");
} }
tname += '+'; tname += '+';
tname += *ptr; tname += *ptr;
...@@ -421,7 +423,7 @@ error inspect(serializer& sink, message& msg) { ...@@ -421,7 +423,7 @@ error inspect(serializer& sink, message& msg) {
} }
error inspect(deserializer& source, message& msg) { error inspect(deserializer& source, message& msg) {
if (!source.context()) if (source.context() == nullptr)
return sec::no_context; return sec::no_context;
uint16_t zero; uint16_t zero;
std::string tname; std::string tname;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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