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

Fix compile on GCC and runtime crash

parent 159aac50
......@@ -30,7 +30,6 @@
#include "caf/ref_counted.hpp"
#include "caf/detail/embedded.hpp"
#include "caf/detail/memory_cache_flag_type.hpp"
namespace caf {
class mailbox_element;
......@@ -114,12 +113,7 @@ public:
static_assert(dsize > 0, "dsize == 0");
using embedded_t =
typename std::conditional<
T::memory_cache_flag == needs_embedding,
embedded<T>,
T
>::type;
using embedded_t = embedded<T>;
struct wrapper {
union {
......@@ -192,12 +186,7 @@ public:
// Allocates storage, initializes a new object, and returns the new instance.
template <class T, class... Ts>
static T* create(Ts&&... xs) {
using embedded_t =
typename std::conditional<
T::memory_cache_flag == needs_embedding,
embedded<T>,
T
>::type;
using embedded_t = embedded<T>;
auto mc = get_or_set_cache_map_entry<T>();
auto es = mc->new_embedded_storage();
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 @@
#include <functional>
#include "caf/atom.hpp"
#include "caf/optional.hpp"
#include "caf/variant.hpp"
#include "caf/optional.hpp"
#include "caf/config_value.hpp"
namespace caf {
namespace detail {
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.
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
/// calls the consumer with every key-value pair.
......
......@@ -64,7 +64,6 @@
#include "caf/detail/behavior_stack.hpp"
#include "caf/detail/typed_actor_util.hpp"
#include "caf/detail/single_reader_queue.hpp"
#include "caf/detail/memory_cache_flag_type.hpp"
namespace caf {
......
......@@ -213,7 +213,10 @@ actor_system_config& actor_system_config::parse(message& args,
// (2) content of the INI file overrides hard-coded defaults
if (ini.good()) {
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
std::string dummy; // caf#config-file either ignored or already open
......
......@@ -29,24 +29,30 @@ namespace detail {
void parse_ini_t::operator()(std::istream& input, config_consumer consumer_fun,
optional<std::ostream&> errors) const {
printf("%s %d\n", __FILE__, __LINE__);
// 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);
};
printf("%s %d\n", __FILE__, __LINE__);
std::string group;
std::string line;
size_t ln = 0; // line number
printf("%s %d\n", __FILE__, __LINE__);
auto print = [&](const char* category, const char* str) {
if (errors)
*errors << category << " INI file line "
<< ln << ": " << str << std::endl;
};
printf("%s %d\n", __FILE__, __LINE__);
auto print_error = [&](const char* str) {
print("[ERROR]", str);
};
printf("%s %d\n", __FILE__, __LINE__);
auto print_warning = [&](const char* str) {
print("[WARNING]", str);
};
printf("%s %d\n", __FILE__, __LINE__);
while (std::getline(input, line)) {
++ln;
// get begin-of-line (bol) and end-of-line (eol), ignoring whitespaces
......
......@@ -91,8 +91,6 @@ public:
}
};
using config_value = detail::parse_ini_t::value;
struct config : actor_system_config {
config() {
parse(test::engine::argc(), test::engine::argv());
......
......@@ -37,8 +37,6 @@
#include "caf/io/network/protocol.hpp"
#include "caf/io/network/native_socket.hpp"
#include "caf/detail/memory_cache_flag_type.hpp"
namespace boost {
namespace asio {
class io_service;
......@@ -144,7 +142,6 @@ public:
template <class F>
void post(F fun) {
struct impl : runnable {
//static constexpr auto memory_cache_flag = detail::needs_embedding;
F f;
impl(F&& mf) : f(std::move(mf)) { }
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