Commit 44f4d5c6 authored by Dominik Charousset's avatar Dominik Charousset

Fix compile on GCC and runtime crash

parent 159aac50
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "caf/ref_counted.hpp" #include "caf/ref_counted.hpp"
#include "caf/detail/embedded.hpp" #include "caf/detail/embedded.hpp"
#include "caf/detail/memory_cache_flag_type.hpp"
namespace caf { namespace caf {
class mailbox_element; class mailbox_element;
...@@ -114,12 +113,7 @@ public: ...@@ -114,12 +113,7 @@ public:
static_assert(dsize > 0, "dsize == 0"); static_assert(dsize > 0, "dsize == 0");
using embedded_t = using embedded_t = embedded<T>;
typename std::conditional<
T::memory_cache_flag == needs_embedding,
embedded<T>,
T
>::type;
struct wrapper { struct wrapper {
union { union {
...@@ -192,12 +186,7 @@ public: ...@@ -192,12 +186,7 @@ public:
// Allocates storage, initializes a new object, and returns the new instance. // Allocates storage, initializes a new object, and returns the new instance.
template <class T, class... Ts> template <class T, class... Ts>
static T* create(Ts&&... xs) { static T* create(Ts&&... xs) {
using embedded_t = using embedded_t = embedded<T>;
typename std::conditional<
T::memory_cache_flag == needs_embedding,
embedded<T>,
T
>::type;
auto mc = get_or_set_cache_map_entry<T>(); auto mc = get_or_set_cache_map_entry<T>();
auto es = mc->new_embedded_storage(); auto es = mc->new_embedded_storage();
auto ptr = reinterpret_cast<embedded_t*>(es.second); auto ptr = reinterpret_cast<embedded_t*>(es.second);
......
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_MEMORY_CACHE_FLAG_TYPE_HPP
#define CAF_DETAIL_MEMORY_CACHE_FLAG_TYPE_HPP
namespace caf {
namespace detail {
enum memory_cache_flag_type {
needs_embedding,
provides_embedding
};
} // namespace detail
} // namespace caf
#endif // CAF_DETAIL_MEMORY_CACHE_FLAG_TYPE_HPP
...@@ -25,18 +25,16 @@ ...@@ -25,18 +25,16 @@
#include <functional> #include <functional>
#include "caf/atom.hpp" #include "caf/atom.hpp"
#include "caf/optional.hpp"
#include "caf/variant.hpp" #include "caf/variant.hpp"
#include "caf/optional.hpp"
#include "caf/config_value.hpp"
namespace caf { namespace caf {
namespace detail { namespace detail {
struct parse_ini_t { struct parse_ini_t {
/// Denotes a configuration value.
using value = variant<std::string, double, int64_t, bool, atom_value>;
/// Denotes a callback for consuming configuration values. /// Denotes a callback for consuming configuration values.
using config_consumer = std::function<void (size_t, std::string, value&)>; using config_consumer = std::function<void (size_t, std::string, config_value&)>;
/// Parse the given input stream as INI formatted data and /// Parse the given input stream as INI formatted data and
/// calls the consumer with every key-value pair. /// calls the consumer with every key-value pair.
......
...@@ -64,7 +64,6 @@ ...@@ -64,7 +64,6 @@
#include "caf/detail/behavior_stack.hpp" #include "caf/detail/behavior_stack.hpp"
#include "caf/detail/typed_actor_util.hpp" #include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/single_reader_queue.hpp" #include "caf/detail/single_reader_queue.hpp"
#include "caf/detail/memory_cache_flag_type.hpp"
namespace caf { namespace caf {
......
...@@ -213,7 +213,10 @@ actor_system_config& actor_system_config::parse(message& args, ...@@ -213,7 +213,10 @@ actor_system_config& actor_system_config::parse(message& args,
// (2) content of the INI file overrides hard-coded defaults // (2) content of the INI file overrides hard-coded defaults
if (ini.good()) { if (ini.good()) {
actor_system_config_reader consumer{options_, custom_options_}; actor_system_config_reader consumer{options_, custom_options_};
detail::parse_ini(ini, consumer, std::cerr); auto f = [&](size_t ln, std::string str, config_value& x) {
consumer(ln, std::move(str), x);
};
detail::parse_ini(ini, f, std::cerr);
} }
// (3) CLI options override the content of the INI file // (3) CLI options override the content of the INI file
std::string dummy; // caf#config-file either ignored or already open std::string dummy; // caf#config-file either ignored or already open
......
...@@ -29,24 +29,30 @@ namespace detail { ...@@ -29,24 +29,30 @@ namespace detail {
void parse_ini_t::operator()(std::istream& input, config_consumer consumer_fun, void parse_ini_t::operator()(std::istream& input, config_consumer consumer_fun,
optional<std::ostream&> errors) const { optional<std::ostream&> errors) const {
printf("%s %d\n", __FILE__, __LINE__);
// wraps a temporary into an (lvalue) config_value and calls `consumer_fun` // wraps a temporary into an (lvalue) config_value and calls `consumer_fun`
auto consumer = [&](size_t ln, std::string name, value x) { auto consumer = [&](size_t ln, std::string name, config_value x) {
consumer_fun(ln, std::move(name), x); consumer_fun(ln, std::move(name), x);
}; };
printf("%s %d\n", __FILE__, __LINE__);
std::string group; std::string group;
std::string line; std::string line;
size_t ln = 0; // line number size_t ln = 0; // line number
printf("%s %d\n", __FILE__, __LINE__);
auto print = [&](const char* category, const char* str) { auto print = [&](const char* category, const char* str) {
if (errors) if (errors)
*errors << category << " INI file line " *errors << category << " INI file line "
<< ln << ": " << str << std::endl; << ln << ": " << str << std::endl;
}; };
printf("%s %d\n", __FILE__, __LINE__);
auto print_error = [&](const char* str) { auto print_error = [&](const char* str) {
print("[ERROR]", str); print("[ERROR]", str);
}; };
printf("%s %d\n", __FILE__, __LINE__);
auto print_warning = [&](const char* str) { auto print_warning = [&](const char* str) {
print("[WARNING]", str); print("[WARNING]", str);
}; };
printf("%s %d\n", __FILE__, __LINE__);
while (std::getline(input, line)) { while (std::getline(input, line)) {
++ln; ++ln;
// get begin-of-line (bol) and end-of-line (eol), ignoring whitespaces // get begin-of-line (bol) and end-of-line (eol), ignoring whitespaces
......
...@@ -91,8 +91,6 @@ public: ...@@ -91,8 +91,6 @@ public:
} }
}; };
using config_value = detail::parse_ini_t::value;
struct config : actor_system_config { struct config : actor_system_config {
config() { config() {
parse(test::engine::argc(), test::engine::argv()); parse(test::engine::argc(), test::engine::argv());
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include "caf/io/network/protocol.hpp" #include "caf/io/network/protocol.hpp"
#include "caf/io/network/native_socket.hpp" #include "caf/io/network/native_socket.hpp"
#include "caf/detail/memory_cache_flag_type.hpp"
namespace boost { namespace boost {
namespace asio { namespace asio {
class io_service; class io_service;
...@@ -144,7 +142,6 @@ public: ...@@ -144,7 +142,6 @@ public:
template <class F> template <class F>
void post(F fun) { void post(F fun) {
struct impl : runnable { struct impl : runnable {
//static constexpr auto memory_cache_flag = detail::needs_embedding;
F f; F f;
impl(F&& mf) : f(std::move(mf)) { } impl(F&& mf) : f(std::move(mf)) { }
resume_result resume(execution_unit*, size_t) override { resume_result resume(execution_unit*, size_t) override {
......
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