Commit bddd8a35 authored by Dominik Charousset's avatar Dominik Charousset

Remove dead code and coding style nitpicks

parent 40b1b4f1
......@@ -215,7 +215,8 @@ client::~client() {
class curl_worker : public base_actor {
public:
curl_worker(const actor& parent)
: base_actor(parent, "curl_worker", color::yellow) {
: base_actor(parent, "curl_worker", color::yellow),
m_curl(nullptr) {
// nop
}
......
......@@ -52,7 +52,6 @@ int main(int argc, char** argv) {
try {
gptr = group::get(group_id.substr(0, p), group_id.substr(p + 1));
} catch (exception& e) {
ostringstream err;
cerr << "*** exception: group::get(\"" << group_id.substr(0, p)
<< "\", \"" << group_id.substr(p + 1) << "\") failed; "
<< to_verbose_string(e) << endl;
......
......@@ -35,17 +35,6 @@ istream& operator>>(istream& is, line& l) {
namespace { string s_last_line; }
message split_line(const line& l) {
istringstream strs(l.str);
s_last_line = move(l.str);
string tmp;
message_builder mb;
while (getline(strs, tmp, ' ')) {
if (!tmp.empty()) mb.append(std::move(tmp));
}
return mb.to_message();
}
void client(event_based_actor* self, const string& name) {
self->become (
[=](broadcast_atom, const string& message) {
......@@ -113,7 +102,6 @@ int main(int argc, char** argv) {
anon_send(client_actor, join_atom::value, g);
}
catch (exception& e) {
ostringstream err;
cerr << "*** exception: group::get(\"" << group_id.substr(0, p)
<< "\", \"" << group_id.substr(p + 1) << "\") failed; "
<< to_verbose_string(e) << endl;
......
/******************************************************************************
* This example shows how to implement serialize/deserialize to announce *
* non-trivial data structures to the libcaf type system. *
* *
* Announce() auto-detects STL compliant containers and provides *
* an easy way to tell libcaf how to serialize user defined types. *
* See announce_example 1-4 for usage examples. *
* *
* You should use "hand written" serialize/deserialize implementations *
* if and only if there is no other way. *
* This example shows how to implement serialize/deserialize to announce *
* non-trivial data structures to the libcaf type system. *
* *
* Announce() auto-detects STL compliant containers and provides *
* an easy way to tell libcaf how to serialize user defined types. *
* See announce_example 1-4 for usage examples. *
* *
* You should use "hand written" serialize/deserialize implementations *
* if and only if there is no other way. *
******************************************************************************/
#include <cstdint>
......
/******************************************************************************
* _________________________ *
* __ ____/__ |__ ____/ C++ *
* _ / __ /| |_ /_ Actor *
* / /___ _ ___ | __/ Framework *
* ____/ /_/ |_/_/ *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENCE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "cppa/to_string.hpp"
#include "cppa/config.hpp"
#include "cppa/message_handler.hpp"
namespace cppa {
message_handler::message_handler(impl_ptr ptr) : m_impl(std::move(ptr)) {}
void detail::behavior_impl::handle_timeout() {}
} // namespace cppa
namespace cppa {
namespace detail {
message_handler combine(behavior_impl_ptr lhs, behavior_impl_ptr rhs) {
return {lhs->or_else(rhs)};
}
behavior_impl_ptr extract(const message_handler& arg) {
return arg.as_behavior_impl();
}
}
} // namespace cppa::detail
......@@ -72,10 +72,3 @@ void pong(blocking_actor* self, actor ping_actor) {
self->send(ping_actor, pong_atom::value, 0); // kickoff
self->receive_loop(pong_behavior(self));
}
void event_based_pong(event_based_actor* self, actor ping_actor) {
CAF_LOGF_TRACE("ping_actor = " << to_string(ping_actor));
CAF_REQUIRE(ping_actor != invalid_actor);
self->send(ping_actor, pong_atom::value, 0); // kickoff
self->become(pong_behavior(self));
}
......@@ -12,8 +12,6 @@ void event_based_ping(caf::event_based_actor*, size_t num_pings);
void pong(caf::blocking_actor*, caf::actor ping_actor);
void event_based_pong(caf::event_based_actor*, caf::actor ping_actor);
// returns the number of messages ping received
size_t pongs();
......
......@@ -14,29 +14,53 @@ int class0_instances = 0;
int class1_instances = 0;
struct class0 : ref_counted {
class0() { ++class0_instances; }
class0(bool subtype = false) : m_subtype(subtype) {
if (!subtype) {
++class0_instances;
}
}
virtual ~class0() { --class0_instances; }
~class0() {
if (!m_subtype) {
--class0_instances;
}
}
virtual class0* create() const { return new class0; }
bool is_subtype() const {
return m_subtype;
}
virtual class0* create() const {
return new class0;
}
bool m_subtype;
};
struct class1 : class0 {
class1() { ++class1_instances; }
virtual ~class1() { --class1_instances; }
class1() : class0(true) {
++class1_instances;
}
virtual class1* create() const { return new class1; }
~class1() {
--class1_instances;
}
class1* create() const override {
return new class1;
}
};
using class0_ptr = intrusive_ptr<class0>;
using class1_ptr = intrusive_ptr<class1>;
class0* get_test_rc() { return new class0; }
class0* get_test_rc() {
return new class0;
}
class0_ptr get_test_ptr() { return get_test_rc(); }
class0_ptr get_test_ptr() {
return get_test_rc();
}
} // namespace <anonymous>
......@@ -51,6 +75,7 @@ int main() {
CAF_CHECK(p->unique());
}
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 0);
{
class0_ptr p;
p = new class0;
......@@ -58,6 +83,7 @@ int main() {
CAF_CHECK(p->unique());
}
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 0);
{
class0_ptr p1;
p1 = get_test_rc();
......@@ -66,6 +92,7 @@ int main() {
CAF_CHECK_EQUAL(p1->unique(), false);
}
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 0);
{
std::list<class0_ptr> pl;
pl.push_back(get_test_ptr());
......@@ -75,19 +102,26 @@ int main() {
CAF_CHECK_EQUAL(class0_instances, 3);
}
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 0);
{
auto p1 = detail::make_counted<class0>();
p1 = new class1;
CAF_CHECK_EQUAL(p1->is_subtype(), false);
CAF_CHECK_EQUAL(p1->unique(), true);
CAF_CHECK_EQUAL(class0_instances, 1);
CAF_CHECK_EQUAL(class1_instances, 0);
p1.reset(new class1);
CAF_CHECK_EQUAL(p1->is_subtype(), true);
CAF_CHECK_EQUAL(p1->unique(), true);
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 1);
auto p2 = detail::make_counted<class1>();
p1 = p2;
CAF_CHECK_EQUAL(class0_instances, 1);
CAF_CHECK_EQUAL(p1->unique(), false);
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 1);
CAF_CHECK(p1 == p2);
}
CAF_CHECK_EQUAL(class0_instances, 0);
CAF_CHECK_EQUAL(class1_instances, 0);
return CAF_TEST_RESULT();
}
......@@ -10,20 +10,6 @@ using namespace std;
using hi_atom = atom_constant<atom("hi")>;
using ho_atom = atom_constant<atom("ho")>;
optional<int> even_int(int i) {
if (i % 2 == 0) {
return i;
}
return none;
}
optional<const vector<int>&> sorted_vec(const vector<int>& vec) {
if (is_sorted(vec.begin(), vec.end())) {
return vec;
}
return none;
}
function<optional<string>(const string&)> starts_with(const string& s) {
return [=](const string& str) -> optional<string> {
cout << "starts_with guard called" << endl;
......@@ -35,14 +21,6 @@ function<optional<string>(const string&)> starts_with(const string& s) {
};
}
optional<vector<string>> kvp_split(const string& str) {
auto pos = str.find('=');
if (pos != string::npos && pos == str.rfind('=')) {
return vector<string>{str.substr(0, pos), str.substr(pos+1)};
}
return none;
}
optional<int> toint(const string& str) {
char* endptr = nullptr;
int result = static_cast<int>(strtol(str.c_str(), &endptr, 10));
......
......@@ -93,9 +93,6 @@ struct raw_struct_type_info : detail::abstract_uniform_type_info<raw_struct> {
rs->str.resize(size);
source->read_raw(size, &(rs->str[0]));
}
bool equals(const void* lhs, const void* rhs) const override {
return deref(lhs) == deref(rhs);
}
};
void test_ieee_754() {
......
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