Commit 55fa3e33 authored by Dominik Charousset's avatar Dominik Charousset

Remove `virtual` keyword from `on_exit`

Unlike d7f07ff4, this change can break client code. However, the fix is as
simple as removing `override` from the member function. Relates #180.
parent d7f07ff4
...@@ -105,7 +105,7 @@ class base_actor : public event_based_actor { ...@@ -105,7 +105,7 @@ class base_actor : public event_based_actor {
return m_out << m_color << m_name << " (id = " << id() << "): "; return m_out << m_color << m_name << " (id = " << id() << "): ";
} }
void on_exit() override { void on_exit() {
print() << "on_exit" << color::reset_endl; print() << "on_exit" << color::reset_endl;
} }
...@@ -256,7 +256,7 @@ class curl_worker : public base_actor { ...@@ -256,7 +256,7 @@ class curl_worker : public base_actor {
); );
} }
void on_exit() override { void on_exit() {
curl_easy_cleanup(m_curl); curl_easy_cleanup(m_curl);
print() << "on_exit" << color::reset_endl; print() << "on_exit" << color::reset_endl;
} }
......
...@@ -8,32 +8,43 @@ ...@@ -8,32 +8,43 @@
* - ./build/bin/group_chat -g remote:chatroom@localhost:4242 -n bob * * - ./build/bin/group_chat -g remote:chatroom@localhost:4242 -n bob *
\ ******************************************************************************/ \ ******************************************************************************/
#include <cstdlib>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "cppa/opt.hpp"
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
using namespace std; using namespace std;
using namespace caf; using namespace caf;
optional<uint16_t> to_port(const string& arg) {
char* last = nullptr;
auto res = strtol(arg.c_str(), &last, 10);
if (last == (arg.c_str() + arg.size()) && res > 1024) {
return res;
}
return none;
}
optional<uint16_t> long_port(const string& arg) {
if (arg.compare(0, 7, "--port=") == 0) {
return to_port(arg.substr(7));
}
return none;
}
int main(int argc, char** argv) { int main(int argc, char** argv) {
uint16_t port = 0; uint16_t port = 0;
options_description desc; message_builder{argv + 1, argv + argc}.apply({
bool args_valid = match_stream<string>(argv + 1, argv + argc) ( (on("-p", to_port) || on(long_port)) >> [&](uint16_t arg) {
on_opt1('p', "port", &desc, "set port") >> rd_arg(port), port = arg;
on_opt0('h', "help", &desc, "print help") >> print_desc_and_exit(&desc) }
); });
if (port <= 1024) { if (port <= 1024) {
cerr << "*** no port > 1024 given" << endl; cerr << "*** no port > 1024 given" << endl;
args_valid = false; cout << "options:" << endl
} << " -p <arg1> | --port=<arg1> set port" << endl;
if (!args_valid) {
// print_desc(&desc) returns a function printing the stored help text
auto desc_printer = print_desc(&desc);
desc_printer();
return 1; return 1;
} }
try { try {
...@@ -57,9 +68,12 @@ int main(int argc, char** argv) { ...@@ -57,9 +68,12 @@ int main(int argc, char** argv) {
cout << "type 'quit' to shutdown the server" << endl; cout << "type 'quit' to shutdown the server" << endl;
string line; string line;
while (getline(cin, line)) { while (getline(cin, line)) {
if (line == "quit") return 0; if (line == "quit") {
else cout << "illegal command" << endl; return 0;
}
else {
cerr << "illegal command" << endl;
}
} }
shutdown(); shutdown();
return 0;
} }
...@@ -368,7 +368,9 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -368,7 +368,9 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
* Can be overridden to perform cleanup code after an actor * Can be overridden to perform cleanup code after an actor
* finished execution. * finished execution.
*/ */
virtual void on_exit(); inline void on_exit() {
// nop
}
/** /**
* Returns all joined groups. * Returns all joined groups.
......
...@@ -57,10 +57,6 @@ void local_actor::demonitor(const actor_addr& whom) { ...@@ -57,10 +57,6 @@ void local_actor::demonitor(const actor_addr& whom) {
ptr->detach({typeid(default_attachable::observe_token), &tk}); ptr->detach({typeid(default_attachable::observe_token), &tk});
} }
void local_actor::on_exit() {
// nop
}
void local_actor::join(const group& what) { void local_actor::join(const group& what) {
CAF_LOG_TRACE(CAF_TSARG(what)); CAF_LOG_TRACE(CAF_TSARG(what));
if (what == invalid_group) { if (what == invalid_group) {
......
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