Commit 8cdb0a4f authored by Dominik Charousset's avatar Dominik Charousset

maintenance

parent 0a2ba938
...@@ -57,7 +57,7 @@ oss << to_string(self->parent_process()) << ": " << __PRETTY_FUNCTION__ << " ->" ...@@ -57,7 +57,7 @@ oss << to_string(self->parent_process()) << ": " << __PRETTY_FUNCTION__ << " ->"
cout << oss.str(); \ cout << oss.str(); \
} ((void) 0) } ((void) 0)
option<int> c_2i(char const* cstr) { option<int> c_2i(const char* cstr) {
char* endptr = nullptr; char* endptr = nullptr;
int result = static_cast<int>(strtol(cstr, &endptr, 10)); int result = static_cast<int>(strtol(cstr, &endptr, 10));
if (endptr == nullptr || *endptr != '\0') { if (endptr == nullptr || *endptr != '\0') {
...@@ -306,7 +306,7 @@ void client_mode(Iterator first, Iterator last) { ...@@ -306,7 +306,7 @@ void client_mode(Iterator first, Iterator last) {
receive_for(i, end) ( receive_for(i, end) (
on(atom("ok")) >> []() { on(atom("ok")) >> []() {
}, },
on(atom("error"), arg_match) >> [&](string const& str) { on(atom("error"), arg_match) >> [&](const string& str) {
cout << "error: " << str << endl; cout << "error: " << str << endl;
for (auto& x : remote_actors) { for (auto& x : remote_actors) {
send(x, atom("purge")); send(x, atom("purge"));
......
...@@ -53,7 +53,7 @@ using std::int64_t; ...@@ -53,7 +53,7 @@ using std::int64_t;
using namespace cppa; using namespace cppa;
template<typename T> template<typename T>
T rd(char const* cstr) { T rd(const char* cstr) {
char* endptr = nullptr; char* endptr = nullptr;
T result = static_cast<T>(strtol(cstr, &endptr, 10)); T result = static_cast<T>(strtol(cstr, &endptr, 10));
if (endptr == nullptr || *endptr != '\0') { if (endptr == nullptr || *endptr != '\0') {
......
...@@ -57,7 +57,7 @@ inline std::string join(const std::vector<std::string>& vec, ...@@ -57,7 +57,7 @@ inline std::string join(const std::vector<std::string>& vec,
} }
template<typename T> template<typename T>
T rd(char const* cstr) { T rd(const char* cstr) {
char* endptr = nullptr; char* endptr = nullptr;
T result = static_cast<T>(strtol(cstr, &endptr, 10)); T result = static_cast<T>(strtol(cstr, &endptr, 10));
if (endptr == nullptr || *endptr != '\0') { if (endptr == nullptr || *endptr != '\0') {
......
...@@ -63,7 +63,6 @@ cppa/detail/map_member.hpp ...@@ -63,7 +63,6 @@ cppa/detail/map_member.hpp
cppa/detail/matches.hpp cppa/detail/matches.hpp
cppa/detail/mock_scheduler.hpp cppa/detail/mock_scheduler.hpp
cppa/detail/native_socket.hpp cppa/detail/native_socket.hpp
cppa/detail/nestable_receive_actor.hpp
cppa/detail/network_manager.hpp cppa/detail/network_manager.hpp
cppa/detail/object_array.hpp cppa/detail/object_array.hpp
cppa/detail/object_impl.hpp cppa/detail/object_impl.hpp
...@@ -81,7 +80,6 @@ cppa/detail/serialize_tuple.hpp ...@@ -81,7 +80,6 @@ cppa/detail/serialize_tuple.hpp
cppa/detail/singleton_manager.hpp cppa/detail/singleton_manager.hpp
cppa/detail/swap_bytes.hpp cppa/detail/swap_bytes.hpp
cppa/detail/tdata.hpp cppa/detail/tdata.hpp
cppa/detail/thread.hpp
cppa/detail/thread_pool_scheduler.hpp cppa/detail/thread_pool_scheduler.hpp
cppa/detail/to_uniform_name.hpp cppa/detail/to_uniform_name.hpp
cppa/detail/tuple_cast_impl.hpp cppa/detail/tuple_cast_impl.hpp
...@@ -270,3 +268,4 @@ unit_testing/test__tuple.cpp ...@@ -270,3 +268,4 @@ unit_testing/test__tuple.cpp
unit_testing/test__type_list.cpp unit_testing/test__type_list.cpp
unit_testing/test__uniform_type.cpp unit_testing/test__uniform_type.cpp
unit_testing/test__yield_interface.cpp unit_testing/test__yield_interface.cpp
cppa/detail/nestable_receive_policy.hpp
...@@ -115,7 +115,7 @@ class any_tuple { ...@@ -115,7 +115,7 @@ class any_tuple {
* @brief Gets {@link uniform_type_info uniform type information} * @brief Gets {@link uniform_type_info uniform type information}
* of the element at position @p p. * of the element at position @p p.
*/ */
uniform_type_info const* type_at(size_t p) const; const uniform_type_info* type_at(size_t p) const;
/** /**
* @brief Returns @c true if <tt>*this == other</tt>, otherwise false. * @brief Returns @c true if <tt>*this == other</tt>, otherwise false.
...@@ -130,7 +130,7 @@ class any_tuple { ...@@ -130,7 +130,7 @@ class any_tuple {
template<typename T> template<typename T>
inline const T& get_as(size_t p) const { inline const T& get_as(size_t p) const {
CPPA_REQUIRE(*(type_at(p)) == typeid(T)); CPPA_REQUIRE(*(type_at(p)) == typeid(T));
return *reinterpret_cast<T const*>(at(p)); return *reinterpret_cast<const T*>(at(p));
} }
template<typename T> template<typename T>
...@@ -147,7 +147,7 @@ class any_tuple { ...@@ -147,7 +147,7 @@ class any_tuple {
inline const cow_ptr<detail::abstract_tuple>& vals() const { return m_vals; } inline const cow_ptr<detail::abstract_tuple>& vals() const { return m_vals; }
inline const cow_ptr<detail::abstract_tuple>& cvals() const { return m_vals; } inline const cow_ptr<detail::abstract_tuple>& cvals() const { return m_vals; }
inline std::type_info const* type_token() const { inline const std::type_info* type_token() const {
return m_vals->type_token(); return m_vals->type_token();
} }
......
...@@ -41,15 +41,15 @@ namespace cppa { ...@@ -41,15 +41,15 @@ namespace cppa {
*/ */
class binary_deserializer : public deserializer { class binary_deserializer : public deserializer {
char const* pos; const char* pos;
char const* end; const char* end;
void range_check(size_t read_size); void range_check(size_t read_size);
public: public:
binary_deserializer(char const* buf, size_t buf_size); binary_deserializer(const char* buf, size_t buf_size);
binary_deserializer(char const* begin, char const* end); binary_deserializer(const char* begin, const char* end);
std::string seek_object(); std::string seek_object();
std::string peek_object(); std::string peek_object();
...@@ -59,7 +59,7 @@ class binary_deserializer : public deserializer { ...@@ -59,7 +59,7 @@ class binary_deserializer : public deserializer {
void end_sequence(); void end_sequence();
primitive_variant read_value(primitive_type ptype); primitive_variant read_value(primitive_type ptype);
void read_tuple(size_t size, void read_tuple(size_t size,
primitive_type const* ptypes, const primitive_type* ptypes,
primitive_variant* storage); primitive_variant* storage);
}; };
......
...@@ -69,7 +69,7 @@ class binary_serializer : public serializer { ...@@ -69,7 +69,7 @@ class binary_serializer : public serializer {
void write_value(const primitive_variant& value); void write_value(const primitive_variant& value);
void write_tuple(size_t size, primitive_variant const* values); void write_tuple(size_t size, const primitive_variant* values);
/** /**
* @brief Returns the number of written bytes. * @brief Returns the number of written bytes.
...@@ -79,11 +79,11 @@ class binary_serializer : public serializer { ...@@ -79,11 +79,11 @@ class binary_serializer : public serializer {
/** /**
* @brief Returns a pointer to the internal buffer. * @brief Returns a pointer to the internal buffer.
*/ */
char const* data() const; const char* data() const;
size_t sendable_size() const; size_t sendable_size() const;
char const* sendable_data(); const char* sendable_data();
/** /**
* @brief Resets the internal buffer. * @brief Resets the internal buffer.
......
...@@ -95,11 +95,11 @@ class cow_ptr { ...@@ -95,11 +95,11 @@ class cow_ptr {
inline T* operator->() { return detached_ptr(); } inline T* operator->() { return detached_ptr(); }
inline T const* get() const { return ptr(); } inline const T* get() const { return ptr(); }
inline const T& operator*() const { return *ptr(); } inline const T& operator*() const { return *ptr(); }
inline T const* operator->() const { return ptr(); } inline const T* operator->() const { return ptr(); }
inline explicit operator bool() const { return static_cast<bool>(m_ptr); } inline explicit operator bool() const { return static_cast<bool>(m_ptr); }
...@@ -119,7 +119,7 @@ class cow_ptr { ...@@ -119,7 +119,7 @@ class cow_ptr {
return ptr; return ptr;
} }
inline T const* ptr() const { return m_ptr.get(); } inline const T* ptr() const { return m_ptr.get(); }
}; };
......
...@@ -154,7 +154,7 @@ class cow_tuple { ...@@ -154,7 +154,7 @@ class cow_tuple {
* @brief Gets {@link uniform_type_info uniform type information} * @brief Gets {@link uniform_type_info uniform type information}
* of the element at position @p p. * of the element at position @p p.
*/ */
inline uniform_type_info const* type_at(size_t p) const { inline const uniform_type_info* type_at(size_t p) const {
return m_vals->type_at(p); return m_vals->type_at(p);
} }
...@@ -212,7 +212,7 @@ cow_tuple<Args...> make_cow_tuple(Args&&... args); ...@@ -212,7 +212,7 @@ cow_tuple<Args...> make_cow_tuple(Args&&... args);
template<size_t N, typename... Types> template<size_t N, typename... Types>
const typename util::at<N, Types...>::type& get(const cow_tuple<Types...>& tup) { const typename util::at<N, Types...>::type& get(const cow_tuple<Types...>& tup) {
typedef typename util::at<N, Types...>::type result_type; typedef typename util::at<N, Types...>::type result_type;
return *reinterpret_cast<result_type const*>(tup.at(N)); return *reinterpret_cast<const result_type*>(tup.at(N));
} }
template<size_t N, typename... Types> template<size_t N, typename... Types>
......
...@@ -367,7 +367,7 @@ ...@@ -367,7 +367,7 @@
* *
* The message passing of @p libcppa prohibits pointers in messages because * The message passing of @p libcppa prohibits pointers in messages because
* it enforces network transparent messaging. * it enforces network transparent messaging.
* Unfortunately, string literals in @p C++ have the type <tt>char const*</tt>, * Unfortunately, string literals in @p C++ have the type <tt>const char*</tt>,
* resp. <tt>const char[]</tt>. Since @p libcppa is a user-friendly library, * resp. <tt>const char[]</tt>. Since @p libcppa is a user-friendly library,
* it silently converts string literals and C-strings to @p std::string objects. * it silently converts string literals and C-strings to @p std::string objects.
* It also converts unicode literals to the corresponding STL container. * It also converts unicode literals to the corresponding STL container.
...@@ -377,7 +377,7 @@ ...@@ -377,7 +377,7 @@
* // sends an std::string containing "hello actor!" to itself * // sends an std::string containing "hello actor!" to itself
* send(self, "hello actor!"); * send(self, "hello actor!");
* *
* char const* cstring = "cstring"; * const char* cstring = "cstring";
* // sends an std::string containing "cstring" to itself * // sends an std::string containing "cstring" to itself
* send(self, cstring); * send(self, cstring);
* *
......
...@@ -105,7 +105,7 @@ class deserializer { ...@@ -105,7 +105,7 @@ class deserializer {
* @param storage Array of size @p num, storing the result of this function. * @param storage Array of size @p num, storing the result of this function.
*/ */
virtual void read_tuple(size_t num, virtual void read_tuple(size_t num,
primitive_type const* ptypes, const primitive_type* ptypes,
primitive_variant* storage ) = 0; primitive_variant* storage ) = 0;
}; };
......
...@@ -66,7 +66,7 @@ class abstract_tuple : public ref_counted { ...@@ -66,7 +66,7 @@ class abstract_tuple : public ref_counted {
virtual size_t size() const = 0; virtual size_t size() const = 0;
virtual abstract_tuple* copy() const = 0; virtual abstract_tuple* copy() const = 0;
virtual const void* at(size_t pos) const = 0; virtual const void* at(size_t pos) const = 0;
virtual uniform_type_info const* type_at(size_t pos) const = 0; virtual const uniform_type_info* type_at(size_t pos) const = 0;
// returns either tdata<...> object or nullptr (default) if tuple // returns either tdata<...> object or nullptr (default) if tuple
// is not a 'native' implementation // is not a 'native' implementation
...@@ -81,7 +81,7 @@ class abstract_tuple : public ref_counted { ...@@ -81,7 +81,7 @@ class abstract_tuple : public ref_counted {
// uniquely identifies this category (element types) of messages // uniquely identifies this category (element types) of messages
// override this member function only if impl_type() == statically_typed // override this member function only if impl_type() == statically_typed
// (default returns &typeid(void)) // (default returns &typeid(void))
virtual std::type_info const* type_token() const; virtual const std::type_info* type_token() const;
bool equals(const abstract_tuple& other) const; bool equals(const abstract_tuple& other) const;
...@@ -109,11 +109,11 @@ struct types_only_eq_type { ...@@ -109,11 +109,11 @@ struct types_only_eq_type {
constexpr types_only_eq_type() { } constexpr types_only_eq_type() { }
template<class Tuple> template<class Tuple>
inline bool operator()(const tuple_iterator<Tuple>& lhs, inline bool operator()(const tuple_iterator<Tuple>& lhs,
uniform_type_info const* rhs ) const { const uniform_type_info* rhs ) const {
return lhs.type() == rhs; return lhs.type() == rhs;
} }
template<class Tuple> template<class Tuple>
inline bool operator()(uniform_type_info const* lhs, inline bool operator()(const uniform_type_info* lhs,
const tuple_iterator<Tuple>& rhs) const { const tuple_iterator<Tuple>& rhs) const {
return lhs == rhs.type(); return lhs == rhs.type();
} }
......
...@@ -50,7 +50,7 @@ class actor_proxy_cache { ...@@ -50,7 +50,7 @@ class actor_proxy_cache {
public: public:
actor_proxy_ptr get(actor_id aid, std::uint32_t process_id, actor_proxy_ptr get(actor_id aid, std::uint32_t process_id,
process_information::node_id_type const& node_id); const process_information::node_id_type& node_id);
// @returns true if pptr was successfully removed, false otherwise // @returns true if pptr was successfully removed, false otherwise
bool erase(const actor_proxy_ptr& pptr); bool erase(const actor_proxy_ptr& pptr);
......
...@@ -59,7 +59,7 @@ constexpr std::uint64_t next_interim(std::uint64_t current, size_t char_code) { ...@@ -59,7 +59,7 @@ constexpr std::uint64_t next_interim(std::uint64_t current, size_t char_code) {
return (current << 6) | encoding_table[(char_code <= 0x7F) ? char_code : 0]; return (current << 6) | encoding_table[(char_code <= 0x7F) ? char_code : 0];
} }
constexpr std::uint64_t atom_val(char const* cstr, std::uint64_t interim = 0) { constexpr std::uint64_t atom_val(const char* cstr, std::uint64_t interim = 0) {
return (*cstr == '\0') ? interim return (*cstr == '\0') ? interim
: atom_val(cstr + 1, : atom_val(cstr + 1,
next_interim(interim, next_interim(interim,
......
...@@ -77,7 +77,7 @@ class container_tuple_view : public abstract_tuple { ...@@ -77,7 +77,7 @@ class container_tuple_view : public abstract_tuple {
return &(*i); return &(*i);
} }
uniform_type_info const* type_at(size_t) const { const uniform_type_info* type_at(size_t) const {
return static_types_array<value_type>::arr[0]; return static_types_array<value_type>::arr[0];
} }
......
...@@ -49,20 +49,18 @@ ...@@ -49,20 +49,18 @@
#include "cppa/exit_reason.hpp" #include "cppa/exit_reason.hpp"
#include "cppa/abstract_actor.hpp" #include "cppa/abstract_actor.hpp"
#include "cppa/intrusive/singly_linked_list.hpp" #include "cppa/intrusive/singly_linked_list.hpp"
#include "cppa/detail/nestable_receive_actor.hpp" #include "cppa/detail/nestable_receive_policy.hpp"
namespace cppa { namespace detail { namespace cppa { namespace detail {
/** /**
* @brief Represents a thread that was converted to an Actor. * @brief Represents a thread that was converted to an Actor.
*/ */
class converted_thread_context class converted_thread_context : public abstract_actor<local_actor> {
: public nestable_receive_actor<converted_thread_context,
abstract_actor<local_actor> > {
typedef nestable_receive_actor<converted_thread_context, friend class nestable_receive_policy;
abstract_actor<local_actor> >
super; typedef abstract_actor<local_actor> super;
public: public:
...@@ -82,6 +80,10 @@ class converted_thread_context ...@@ -82,6 +80,10 @@ class converted_thread_context
inline decltype(m_mailbox)& mailbox() { return m_mailbox; } inline decltype(m_mailbox)& mailbox() { return m_mailbox; }
private:
nestable_receive_policy m_recv_policy;
}; };
} } // namespace cppa::detail } } // namespace cppa::detail
......
...@@ -91,12 +91,12 @@ class decorated_tuple : public abstract_tuple { ...@@ -91,12 +91,12 @@ class decorated_tuple : public abstract_tuple {
return m_decorated->at(m_mapping[pos]); return m_decorated->at(m_mapping[pos]);
} }
virtual uniform_type_info const* type_at(size_t pos) const { virtual const uniform_type_info* type_at(size_t pos) const {
CPPA_REQUIRE(pos < size()); CPPA_REQUIRE(pos < size());
return m_decorated->type_at(m_mapping[pos]); return m_decorated->type_at(m_mapping[pos]);
} }
std::type_info const* type_token() const { const std::type_info* type_token() const {
return static_type_list<ElementTypes...>::list; return static_type_list<ElementTypes...>::list;
} }
......
...@@ -110,11 +110,11 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T ...@@ -110,11 +110,11 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
uniform_type_info* m_meta; uniform_type_info* m_meta;
std::function<void (uniform_type_info const*, std::function<void (const uniform_type_info*,
const void*, const void*,
serializer* )> m_serialize; serializer* )> m_serialize;
std::function<void (uniform_type_info const*, std::function<void (const uniform_type_info*,
void*, void*,
deserializer* )> m_deserialize; deserializer* )> m_deserialize;
...@@ -138,12 +138,12 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T ...@@ -138,12 +138,12 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
template<typename R, class C> template<typename R, class C>
member(uniform_type_info* mtptr, R C::*mem_ptr) : m_meta(mtptr) { member(uniform_type_info* mtptr, R C::*mem_ptr) : m_meta(mtptr) {
m_serialize = [mem_ptr] (uniform_type_info const* mt, m_serialize = [mem_ptr] (const uniform_type_info* mt,
const void* obj, const void* obj,
serializer* s) { serializer* s) {
mt->serialize(&(*reinterpret_cast<C const*>(obj).*mem_ptr), s); mt->serialize(&(*reinterpret_cast<const C*>(obj).*mem_ptr), s);
}; };
m_deserialize = [mem_ptr] (uniform_type_info const* mt, m_deserialize = [mem_ptr] (const uniform_type_info* mt,
void* obj, void* obj,
deserializer* d) { deserializer* d) {
mt->deserialize(&(*reinterpret_cast<C*>(obj).*mem_ptr), d); mt->deserialize(&(*reinterpret_cast<C*>(obj).*mem_ptr), d);
...@@ -158,13 +158,13 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T ...@@ -158,13 +158,13 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
typedef typename util::rm_ref<SArg>::type setter_arg; typedef typename util::rm_ref<SArg>::type setter_arg;
static_assert(std::is_same<getter_result, setter_arg>::value, static_assert(std::is_same<getter_result, setter_arg>::value,
"getter result doesn't match setter argument"); "getter result doesn't match setter argument");
m_serialize = [getter] (uniform_type_info const* mt, m_serialize = [getter] (const uniform_type_info* mt,
const void* obj, const void* obj,
serializer* s) { serializer* s) {
GRes v = (*reinterpret_cast<C const*>(obj).*getter)(); GRes v = (*reinterpret_cast<const C*>(obj).*getter)();
mt->serialize(&v, s); mt->serialize(&v, s);
}; };
m_deserialize = [setter] (uniform_type_info const* mt, m_deserialize = [setter] (const uniform_type_info* mt,
void* obj, void* obj,
deserializer* d) { deserializer* d) {
setter_arg value; setter_arg value;
...@@ -181,10 +181,10 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T ...@@ -181,10 +181,10 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
static member fake_member(uniform_type_info* mtptr) { static member fake_member(uniform_type_info* mtptr) {
return { return {
mtptr, mtptr,
[] (uniform_type_info const* mt, const void* obj, serializer* s) { [] (const uniform_type_info* mt, const void* obj, serializer* s) {
mt->serialize(obj, s); mt->serialize(obj, s);
}, },
[] (uniform_type_info const* mt, void* obj, deserializer* d) { [] (const uniform_type_info* mt, void* obj, deserializer* d) {
mt->deserialize(obj, d); mt->deserialize(obj, d);
} }
}; };
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
namespace cppa { namespace detail { namespace cppa { namespace detail {
std::string demangle(char const* typeid_name); std::string demangle(const char* typeid_name);
} } // namespace cppa::detail } } // namespace cppa::detail
......
...@@ -47,8 +47,8 @@ class empty_tuple : public abstract_tuple { ...@@ -47,8 +47,8 @@ class empty_tuple : public abstract_tuple {
abstract_tuple* copy() const; abstract_tuple* copy() const;
const void* at(size_t) const; const void* at(size_t) const;
bool equals(const abstract_tuple& other) const; bool equals(const abstract_tuple& other) const;
uniform_type_info const* type_at(size_t) const; const uniform_type_info* type_at(size_t) const;
std::type_info const* type_token() const; const std::type_info* type_token() const;
}; };
......
...@@ -48,7 +48,7 @@ namespace cppa { namespace detail { ...@@ -48,7 +48,7 @@ namespace cppa { namespace detail {
template<typename T> template<typename T>
struct implicit_conversions { struct implicit_conversions {
typedef typename util::replace_type<T, std::string, typedef typename util::replace_type<T, std::string,
std::is_same<T, char const*>, std::is_same<T, const char*>,
std::is_same<T, char*>, std::is_same<T, char*>,
util::is_array_of<T, char>, util::is_array_of<T, char>,
util::is_array_of<T, const char> >::type util::is_array_of<T, const char> >::type
......
...@@ -61,7 +61,7 @@ template<typename List> ...@@ -61,7 +61,7 @@ template<typename List>
struct list_member_util<List, false> { struct list_member_util<List, false> {
typedef typename List::value_type value_type; typedef typename List::value_type value_type;
uniform_type_info const* m_value_type; const uniform_type_info* m_value_type;
list_member_util() : m_value_type(uniform_typeid<value_type>()) { list_member_util() : m_value_type(uniform_typeid<value_type>()) {
} }
...@@ -95,7 +95,7 @@ class list_member : public util::abstract_uniform_type_info<List> { ...@@ -95,7 +95,7 @@ class list_member : public util::abstract_uniform_type_info<List> {
public: public:
void serialize(const void* obj, serializer* s) const { void serialize(const void* obj, serializer* s) const {
auto& list = *reinterpret_cast<List const*>(obj); auto& list = *reinterpret_cast<const List*>(obj);
m_helper(list, s); m_helper(list, s);
} }
......
...@@ -67,7 +67,7 @@ struct map_member_util<T, false, true> { ...@@ -67,7 +67,7 @@ struct map_member_util<T, false, true> {
// std::set with non-primitive value // std::set with non-primitive value
template<typename T> template<typename T>
struct map_member_util<T, false, false> { struct map_member_util<T, false, false> {
uniform_type_info const* m_type; const uniform_type_info* m_type;
map_member_util() : m_type(uniform_typeid<T>()) { map_member_util() : m_type(uniform_typeid<T>()) {
} }
...@@ -125,7 +125,7 @@ class map_member : public util::abstract_uniform_type_info<Map> { ...@@ -125,7 +125,7 @@ class map_member : public util::abstract_uniform_type_info<Map> {
public: public:
void serialize(const void* obj, serializer* s) const { void serialize(const void* obj, serializer* s) const {
auto& mp = *reinterpret_cast<Map const*>(obj); auto& mp = *reinterpret_cast<const Map*>(obj);
s->begin_sequence(mp.size()); s->begin_sequence(mp.size());
for (const auto& val : mp) { for (const auto& val : mp) {
m_helper.serialize_value(val, s); m_helper.serialize_value(val, s);
......
...@@ -46,7 +46,7 @@ namespace cppa { namespace detail { ...@@ -46,7 +46,7 @@ namespace cppa { namespace detail {
#ifdef CPPA_WINDOWS #ifdef CPPA_WINDOWS
typedef SOCKET native_socket_type; typedef SOCKET native_socket_type;
typedef char const* socket_send_ptr; typedef const char* socket_send_ptr;
typedef char* socket_recv_ptr; typedef char* socket_recv_ptr;
constexpr SOCKET invalid_socket = INVALID_SOCKET; constexpr SOCKET invalid_socket = INVALID_SOCKET;
#else #else
......
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
\******************************************************************************/ \******************************************************************************/
#ifndef NESTABLE_RECEIVE_ACTOR_HPP #ifndef NESTABLE_RECEIVE_POLICY_HPP
#define NESTABLE_RECEIVE_ACTOR_HPP #define NESTABLE_RECEIVE_POLICY_HPP
#include <list>
#include <memory> #include <memory>
#include "cppa/config.hpp"
#include "cppa/behavior.hpp" #include "cppa/behavior.hpp"
#include "cppa/partial_function.hpp" #include "cppa/partial_function.hpp"
#include "cppa/detail/filter_result.hpp" #include "cppa/detail/filter_result.hpp"
...@@ -41,10 +41,9 @@ ...@@ -41,10 +41,9 @@
namespace cppa { namespace detail { namespace cppa { namespace detail {
template<class Derived, class Base> class nestable_receive_policy {
class nestable_receive_actor : public Base {
protected: public:
enum handle_message_result { enum handle_message_result {
hm_timeout_msg, hm_timeout_msg,
...@@ -54,19 +53,19 @@ class nestable_receive_actor : public Base { ...@@ -54,19 +53,19 @@ class nestable_receive_actor : public Base {
hm_success hm_success
}; };
template<class FunOrBehavior> template<class Client, class FunOrBehavior>
bool invoke_from_cache(FunOrBehavior& fun) { bool invoke_from_cache(Client* client, FunOrBehavior& fun) {
auto i = m_cache.begin(); auto i = m_cache.begin();
auto e = m_cache.end(); auto e = m_cache.end();
while (i != e) { while (i != e) {
switch (this->handle_message(*(*i), fun)) { switch (this->handle_message(client, *(*i), fun)) {
case hm_success: { case hm_success: {
this->release_node(i->release()); client->release_node(i->release());
m_cache.erase(i); m_cache.erase(i);
return true; return true;
} }
case hm_drop_msg: { case hm_drop_msg: {
this->release_node(i->release()); client->release_node(i->release());
i = m_cache.erase(i); i = m_cache.erase(i);
break; break;
} }
...@@ -83,15 +82,15 @@ class nestable_receive_actor : public Base { ...@@ -83,15 +82,15 @@ class nestable_receive_actor : public Base {
return false; return false;
} }
template<class FunOrBehavior> template<class Client, class FunOrBehavior>
bool invoke(recursive_queue_node* node, FunOrBehavior& fun) { bool invoke(Client* client, recursive_queue_node* node, FunOrBehavior& fun) {
switch (this->handle_message(*node, fun)) { switch (this->handle_message(client, *node, fun)) {
case hm_success: { case hm_success: {
this->release_node(node); client->release_node(node);
return true; return true;
} }
case hm_drop_msg: { case hm_drop_msg: {
this->release_node(node); client->release_node(node);
break; break;
} }
case hm_cache_msg: { case hm_cache_msg: {
...@@ -112,29 +111,22 @@ class nestable_receive_actor : public Base { ...@@ -112,29 +111,22 @@ class nestable_receive_actor : public Base {
std::list<std::unique_ptr<recursive_queue_node> > m_cache; std::list<std::unique_ptr<recursive_queue_node> > m_cache;
inline Derived* dthis() { inline void handle_timeout(behavior& bhvr) {
return static_cast<Derived*>(this);
}
inline Derived const* dthis() const {
return static_cast<Derived const*>(this);
}
void handle_timeout(behavior& bhvr) {
bhvr.handle_timeout(); bhvr.handle_timeout();
} }
void handle_timeout(partial_function&) { inline void handle_timeout(partial_function&) {
CPPA_CRITICAL("handle_timeout(partial_function&)"); CPPA_CRITICAL("handle_timeout(partial_function&)");
} }
template<class FunOrBehavior> template<class Client, class FunOrBehavior>
handle_message_result handle_message(recursive_queue_node& node, handle_message_result handle_message(Client* client,
recursive_queue_node& node,
FunOrBehavior& fun) { FunOrBehavior& fun) {
if (node.marked) { if (node.marked) {
return hm_skip_msg; return hm_skip_msg;
} }
switch (dthis()->filter_msg(node.msg)) { switch (client->filter_msg(node.msg)) {
case normal_exit_signal: case normal_exit_signal:
case expired_timeout_message: { case expired_timeout_message: {
return hm_drop_msg; return hm_drop_msg;
...@@ -150,19 +142,19 @@ class nestable_receive_actor : public Base { ...@@ -150,19 +142,19 @@ class nestable_receive_actor : public Base {
CPPA_CRITICAL("illegal result of filter_msg"); CPPA_CRITICAL("illegal result of filter_msg");
} }
} }
std::swap(this->m_last_dequeued, node.msg); std::swap(client->m_last_dequeued, node.msg);
std::swap(this->m_last_sender, node.sender); std::swap(client->m_last_sender, node.sender);
dthis()->push_timeout(); client->push_timeout();
node.marked = true; node.marked = true;
if (fun(this->m_last_dequeued)) { if (fun(client->m_last_dequeued)) {
this->m_last_dequeued.reset(); client->m_last_dequeued.reset();
this->m_last_sender.reset(); client->m_last_sender.reset();
return hm_success; return hm_success;
} }
// no match (restore members) // no match (restore client members)
std::swap(this->m_last_dequeued, node.msg); std::swap(client->m_last_dequeued, node.msg);
std::swap(this->m_last_sender, node.sender); std::swap(client->m_last_sender, node.sender);
dthis()->pop_timeout(); client->pop_timeout();
node.marked = false; node.marked = false;
return hm_cache_msg; return hm_cache_msg;
} }
...@@ -171,4 +163,4 @@ class nestable_receive_actor : public Base { ...@@ -171,4 +163,4 @@ class nestable_receive_actor : public Base {
} } // namespace cppa::detail } } // namespace cppa::detail
#endif // NESTABLE_RECEIVE_ACTOR_HPP #endif // NESTABLE_RECEIVE_POLICY_HPP
...@@ -65,7 +65,7 @@ class object_array : public abstract_tuple { ...@@ -65,7 +65,7 @@ class object_array : public abstract_tuple {
bool equals(const cppa::detail::abstract_tuple&) const; bool equals(const cppa::detail::abstract_tuple&) const;
uniform_type_info const* type_at(size_t pos) const; const uniform_type_info* type_at(size_t pos) const;
private: private:
......
...@@ -55,7 +55,7 @@ class pair_member : public util::abstract_uniform_type_info<std::pair<T1,T2>> { ...@@ -55,7 +55,7 @@ class pair_member : public util::abstract_uniform_type_info<std::pair<T1,T2>> {
public: public:
void serialize(const void* obj, serializer* s) const { void serialize(const void* obj, serializer* s) const {
auto& p = *reinterpret_cast<pair_type const*>(obj); auto& p = *reinterpret_cast<const pair_type*>(obj);
primitive_variant values[2] = { p.first, p.second }; primitive_variant values[2] = { p.first, p.second };
s->write_tuple(2, values); s->write_tuple(2, values);
} }
......
...@@ -51,7 +51,7 @@ class primitive_member : public util::abstract_uniform_type_info<T> { ...@@ -51,7 +51,7 @@ class primitive_member : public util::abstract_uniform_type_info<T> {
public: public:
void serialize(const void* obj, serializer* s) const { void serialize(const void* obj, serializer* s) const {
s->write_value(*reinterpret_cast<T const*>(obj)); s->write_value(*reinterpret_cast<const T*>(obj));
} }
void deserialize(void* obj, deserializer* d) const { void deserialize(void* obj, deserializer* d) const {
......
...@@ -70,7 +70,7 @@ namespace cppa { ...@@ -70,7 +70,7 @@ namespace cppa {
template<size_t N, typename... Tn> template<size_t N, typename... Tn>
const typename util::at<N, Tn...>::type& get(const detail::pseudo_tuple<Tn...>& tv) { const typename util::at<N, Tn...>::type& get(const detail::pseudo_tuple<Tn...>& tv) {
static_assert(N < sizeof...(Tn), "N >= tv.size()"); static_assert(N < sizeof...(Tn), "N >= tv.size()");
return *reinterpret_cast<typename util::at<N, Tn...>::type const*>(tv.at(N)); return *reinterpret_cast<const typename util::at<N, Tn...>::type*>(tv.at(N));
} }
template<size_t N, typename... Tn> template<size_t N, typename... Tn>
......
...@@ -53,7 +53,7 @@ struct recursive_queue_node { ...@@ -53,7 +53,7 @@ struct recursive_queue_node {
} }
recursive_queue_node(recursive_queue_node&&) = delete; recursive_queue_node(recursive_queue_node&&) = delete;
recursive_queue_node(recursive_queue_node const&) = delete; recursive_queue_node(const recursive_queue_node&) = delete;
recursive_queue_node& operator=(recursive_queue_node&&) = delete; recursive_queue_node& operator=(recursive_queue_node&&) = delete;
recursive_queue_node& operator=(const recursive_queue_node&) = delete; recursive_queue_node& operator=(const recursive_queue_node&) = delete;
......
...@@ -43,7 +43,7 @@ namespace cppa { namespace detail { ...@@ -43,7 +43,7 @@ namespace cppa { namespace detail {
template<typename List, size_t Pos = 0> template<typename List, size_t Pos = 0>
struct serialize_tuple { struct serialize_tuple {
template<typename T> template<typename T>
inline static void _(serializer& s, T const* tup) { inline static void _(serializer& s, const T* tup) {
s << uniform_typeid<typename List::head>()->name() s << uniform_typeid<typename List::head>()->name()
<< *reinterpret_cast<const typename List::head*>(tup->at(Pos)); << *reinterpret_cast<const typename List::head*>(tup->at(Pos));
serialize_tuple<typename List::tail, Pos + 1>::_(s, tup); serialize_tuple<typename List::tail, Pos + 1>::_(s, tup);
...@@ -53,7 +53,7 @@ struct serialize_tuple { ...@@ -53,7 +53,7 @@ struct serialize_tuple {
template<size_t Pos> template<size_t Pos>
struct serialize_tuple<util::type_list<>, Pos> { struct serialize_tuple<util::type_list<>, Pos> {
template<typename T> template<typename T>
inline static void _(serializer&, T const*) { } inline static void _(serializer&, const T*) { }
}; };
} } // namespace cppa::detail } } // namespace cppa::detail
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
namespace cppa { namespace cppa {
class uniform_type_info; class uniform_type_info;
uniform_type_info const* uniform_typeid(const std::type_info&); const uniform_type_info* uniform_typeid(const std::type_info&);
} // namespace cppa } // namespace cppa
namespace cppa { namespace detail { namespace cppa { namespace detail {
...@@ -66,7 +66,7 @@ template<typename T> ...@@ -66,7 +66,7 @@ template<typename T>
inline void* ptr_to(T* what) { return what; } inline void* ptr_to(T* what) { return what; }
template<typename T> template<typename T>
inline const void* ptr_to(T const* what) { return what; } inline const void* ptr_to(const T* what) { return what; }
template<typename T> template<typename T>
inline void* ptr_to(const std::reference_wrapper<T>& what) { inline void* ptr_to(const std::reference_wrapper<T>& what) {
...@@ -79,17 +79,17 @@ inline const void* ptr_to(const std::reference_wrapper<const T>& what) { ...@@ -79,17 +79,17 @@ inline const void* ptr_to(const std::reference_wrapper<const T>& what) {
} }
template<typename T> template<typename T>
inline uniform_type_info const* utype_of(const T&) { inline const uniform_type_info* utype_of(const T&) {
return static_types_array<T>::arr[0]; return static_types_array<T>::arr[0];
} }
template<typename T> template<typename T>
inline uniform_type_info const* utype_of(const std::reference_wrapper<T>&) { inline const uniform_type_info* utype_of(const std::reference_wrapper<T>&) {
return static_types_array<typename util::rm_ref<T>::type>::arr[0]; return static_types_array<typename util::rm_ref<T>::type>::arr[0];
} }
template<typename T> template<typename T>
inline uniform_type_info const* utype_of(T const* ptr) { inline const uniform_type_info* utype_of(const T* ptr) {
return utype_of(*ptr); return utype_of(*ptr);
} }
...@@ -168,7 +168,7 @@ struct tdata<> { ...@@ -168,7 +168,7 @@ struct tdata<> {
throw std::out_of_range("tdata<>"); throw std::out_of_range("tdata<>");
} }
inline uniform_type_info const* type_at(size_t) const { inline const uniform_type_info* type_at(size_t) const {
throw std::out_of_range("tdata<>"); throw std::out_of_range("tdata<>");
} }
...@@ -336,7 +336,7 @@ struct tdata<Head, Tail...> : tdata<Tail...> { ...@@ -336,7 +336,7 @@ struct tdata<Head, Tail...> : tdata<Tail...> {
} }
inline uniform_type_info const* type_at(size_t p) const { inline const uniform_type_info* type_at(size_t p) const {
return (p == 0) ? utype_of(head) : super::type_at(p-1); return (p == 0) ? utype_of(head) : super::type_at(p-1);
} }
......
...@@ -41,11 +41,11 @@ template<class Tuple> ...@@ -41,11 +41,11 @@ template<class Tuple>
class tuple_iterator { class tuple_iterator {
size_t m_pos; size_t m_pos;
Tuple const* m_tuple; const Tuple* m_tuple;
public: public:
inline tuple_iterator(Tuple const* tup, size_t pos = 0) inline tuple_iterator(const Tuple* tup, size_t pos = 0)
: m_pos(pos), m_tuple(tup) { : m_pos(pos), m_tuple(tup) {
} }
...@@ -99,7 +99,7 @@ class tuple_iterator { ...@@ -99,7 +99,7 @@ class tuple_iterator {
return m_tuple->at(m_pos); return m_tuple->at(m_pos);
} }
inline uniform_type_info const* type() const { inline const uniform_type_info* type() const {
return m_tuple->type_at(m_pos); return m_tuple->type_at(m_pos);
} }
......
...@@ -100,21 +100,21 @@ class tuple_vals : public abstract_tuple { ...@@ -100,21 +100,21 @@ class tuple_vals : public abstract_tuple {
return const_cast<void*>(at(pos)); return const_cast<void*>(at(pos));
} }
uniform_type_info const* type_at(size_t pos) const { const uniform_type_info* type_at(size_t pos) const {
CPPA_REQUIRE(pos < size()); CPPA_REQUIRE(pos < size());
return m_types[pos]; return m_types[pos];
} }
bool equals(const abstract_tuple& other) const { bool equals(const abstract_tuple& other) const {
if (size() != other.size()) return false; if (size() != other.size()) return false;
tuple_vals const* o = dynamic_cast<tuple_vals const*>(&other); const tuple_vals* o = dynamic_cast<const tuple_vals*>(&other);
if (o) { if (o) {
return m_data == (o->m_data); return m_data == (o->m_data);
} }
return abstract_tuple::equals(other); return abstract_tuple::equals(other);
} }
std::type_info const* type_token() const { const std::type_info* type_token() const {
return detail::static_type_list<ElementTypes...>::list; return detail::static_type_list<ElementTypes...>::list;
} }
......
...@@ -43,7 +43,7 @@ struct tuple_view_copy_helper { ...@@ -43,7 +43,7 @@ struct tuple_view_copy_helper {
abstract_tuple* target; abstract_tuple* target;
tuple_view_copy_helper(abstract_tuple* trgt) : pos(0), target(trgt) { } tuple_view_copy_helper(abstract_tuple* trgt) : pos(0), target(trgt) { }
template<typename T> template<typename T>
void operator()(T const* value) { void operator()(const T* value) {
*(reinterpret_cast<T*>(target->mutable_at(pos++))) = *value; *(reinterpret_cast<T*>(target->mutable_at(pos++))) = *value;
} }
}; };
...@@ -101,12 +101,12 @@ class tuple_view : public abstract_tuple { ...@@ -101,12 +101,12 @@ class tuple_view : public abstract_tuple {
return m_data.mutable_at(pos); return m_data.mutable_at(pos);
} }
uniform_type_info const* type_at(size_t pos) const { const uniform_type_info* type_at(size_t pos) const {
CPPA_REQUIRE(pos < size()); CPPA_REQUIRE(pos < size());
return m_types[pos]; return m_types[pos];
} }
std::type_info const* type_token() const { const std::type_info* type_token() const {
return detail::static_type_list<ElementTypes...>::list; return detail::static_type_list<ElementTypes...>::list;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
// forward declarations // forward declarations
namespace cppa { namespace cppa {
class uniform_type_info; class uniform_type_info;
uniform_type_info const* uniform_typeid(const std::type_info&); const uniform_type_info* uniform_typeid(const std::type_info&);
} // namespace cppa } // namespace cppa
namespace cppa { namespace detail { namespace cppa { namespace detail {
...@@ -24,29 +24,29 @@ struct ta_util; ...@@ -24,29 +24,29 @@ struct ta_util;
template<bool IsBuiltin, typename T> template<bool IsBuiltin, typename T>
struct ta_util<std_tinf, IsBuiltin, T> { struct ta_util<std_tinf, IsBuiltin, T> {
static inline std::type_info const* get() { return &(typeid(T)); } static inline const std::type_info* get() { return &(typeid(T)); }
}; };
template<> template<>
struct ta_util<std_tinf, true, anything> { struct ta_util<std_tinf, true, anything> {
static inline std::type_info const* get() { return nullptr; } static inline const std::type_info* get() { return nullptr; }
}; };
template<typename T> template<typename T>
struct ta_util<cppa_tinf, true, T> { struct ta_util<cppa_tinf, true, T> {
static inline uniform_type_info const* get() { static inline const uniform_type_info* get() {
return uniform_typeid(typeid(T)); return uniform_typeid(typeid(T));
} }
}; };
template<> template<>
struct ta_util<cppa_tinf, true, anything> { struct ta_util<cppa_tinf, true, anything> {
static inline uniform_type_info const* get() { return nullptr; } static inline const uniform_type_info* get() { return nullptr; }
}; };
template<typename T> template<typename T>
struct ta_util<cppa_tinf, false, T> { struct ta_util<cppa_tinf, false, T> {
static inline uniform_type_info const* get() { return nullptr; } static inline const uniform_type_info* get() { return nullptr; }
}; };
// implements types_array // implements types_array
...@@ -54,12 +54,12 @@ template<bool BuiltinOnlyTypes, typename... T> ...@@ -54,12 +54,12 @@ template<bool BuiltinOnlyTypes, typename... T>
struct types_array_impl { struct types_array_impl {
static constexpr bool builtin_only = true; static constexpr bool builtin_only = true;
// all types are builtin, perform lookup on constuction // all types are builtin, perform lookup on constuction
uniform_type_info const* data[sizeof...(T)]; const uniform_type_info* data[sizeof...(T)];
types_array_impl() : data{ta_util<cppa_tinf, true, T>::get()...} { } types_array_impl() : data{ta_util<cppa_tinf, true, T>::get()...} { }
inline uniform_type_info const* operator[](size_t p) const { inline const uniform_type_info* operator[](size_t p) const {
return data[p]; return data[p];
} }
typedef uniform_type_info const* const* const_iterator; typedef const uniform_type_info* const* const_iterator;
inline const_iterator begin() const { return std::begin(data); } inline const_iterator begin() const { return std::begin(data); }
inline const_iterator end() const { return std::end(data); } inline const_iterator end() const { return std::end(data); }
}; };
...@@ -68,11 +68,11 @@ template<typename... T> ...@@ -68,11 +68,11 @@ template<typename... T>
struct types_array_impl<false, T...> { struct types_array_impl<false, T...> {
static constexpr bool builtin_only = false; static constexpr bool builtin_only = false;
// contains std::type_info for all non-builtin types // contains std::type_info for all non-builtin types
std::type_info const* tinfo_data[sizeof...(T)]; const std::type_info* tinfo_data[sizeof...(T)];
// contains uniform_type_infos for builtin types and lazy initializes // contains uniform_type_infos for builtin types and lazy initializes
// non-builtin types at runtime // non-builtin types at runtime
mutable std::atomic<uniform_type_info const*> data[sizeof...(T)]; mutable std::atomic<const uniform_type_info*> data[sizeof...(T)];
mutable std::atomic<uniform_type_info const* *> pairs; mutable std::atomic<const uniform_type_info* *> pairs;
// pairs[sizeof...(T)]; // pairs[sizeof...(T)];
types_array_impl() types_array_impl()
: tinfo_data{ta_util<std_tinf,util::is_builtin<T>::value,T>::get()...} { : tinfo_data{ta_util<std_tinf,util::is_builtin<T>::value,T>::get()...} {
...@@ -85,7 +85,7 @@ struct types_array_impl<false, T...> { ...@@ -85,7 +85,7 @@ struct types_array_impl<false, T...> {
} }
} }
} }
inline uniform_type_info const* operator[](size_t p) const { inline const uniform_type_info* operator[](size_t p) const {
auto result = data[p].load(); auto result = data[p].load();
if (result == nullptr) { if (result == nullptr) {
auto tinfo = tinfo_data[p]; auto tinfo = tinfo_data[p];
...@@ -96,11 +96,11 @@ struct types_array_impl<false, T...> { ...@@ -96,11 +96,11 @@ struct types_array_impl<false, T...> {
} }
return result; return result;
} }
typedef uniform_type_info const* const* const_iterator; typedef const uniform_type_info* const* const_iterator;
inline const_iterator begin() const { inline const_iterator begin() const {
auto result = pairs.load(); auto result = pairs.load();
if (result == nullptr) { if (result == nullptr) {
auto parr = new uniform_type_info const*[sizeof...(T)]; auto parr = new const uniform_type_info*[sizeof...(T)];
for (size_t i = 0; i < sizeof...(T); ++i) { for (size_t i = 0; i < sizeof...(T); ++i) {
parr[i] = (*this)[i]; parr[i] = (*this)[i];
} }
...@@ -152,11 +152,11 @@ struct static_types_array_from_type_list<util::type_list<T...>> { ...@@ -152,11 +152,11 @@ struct static_types_array_from_type_list<util::type_list<T...>> {
// utility for singleton-like access to a type_info instance of a type_list // utility for singleton-like access to a type_info instance of a type_list
template<typename... T> template<typename... T>
struct static_type_list { struct static_type_list {
static std::type_info const* list; static const std::type_info* list;
}; };
template<typename... T> template<typename... T>
std::type_info const* static_type_list<T...>::list = &typeid(util::type_list<T...>); const std::type_info* static_type_list<T...>::list = &typeid(util::type_list<T...>);
} } // namespace cppa::detail } } // namespace cppa::detail
......
...@@ -41,18 +41,16 @@ ...@@ -41,18 +41,16 @@
#include "cppa/pattern.hpp" #include "cppa/pattern.hpp"
#include "cppa/detail/yield_interface.hpp" #include "cppa/detail/yield_interface.hpp"
#include "cppa/detail/nestable_receive_actor.hpp" #include "cppa/detail/nestable_receive_policy.hpp"
#include "cppa/detail/abstract_scheduled_actor.hpp" #include "cppa/detail/abstract_scheduled_actor.hpp"
namespace cppa { namespace detail { namespace cppa { namespace detail {
class yielding_actor class yielding_actor : public abstract_scheduled_actor {
: public nestable_receive_actor<yielding_actor,
abstract_scheduled_actor> {
typedef nestable_receive_actor<yielding_actor, friend class nestable_receive_policy;
abstract_scheduled_actor>
super; typedef abstract_scheduled_actor super;
public: public:
...@@ -76,12 +74,15 @@ class yielding_actor ...@@ -76,12 +74,15 @@ class yielding_actor
typedef std::unique_ptr<recursive_queue_node> queue_node_ptr; typedef std::unique_ptr<recursive_queue_node> queue_node_ptr;
static void run(void* _this); void run();
static void trampoline(void* _this);
void yield_until_not_empty(); void yield_until_not_empty();
util::fiber m_fiber; util::fiber m_fiber;
std::function<void()> m_behavior; std::function<void()> m_behavior;
nestable_receive_policy m_recv_policy;
inline recursive_queue_node* receive_node() { inline recursive_queue_node* receive_node() {
recursive_queue_node* e = m_mailbox.try_pop(); recursive_queue_node* e = m_mailbox.try_pop();
......
...@@ -51,7 +51,7 @@ class exception : public std::exception { ...@@ -51,7 +51,7 @@ class exception : public std::exception {
* @brief Returns the error message. * @brief Returns the error message.
* @returns The error message as C-string. * @returns The error message as C-string.
*/ */
char const* what() const throw(); const char* what() const throw();
protected: protected:
......
...@@ -128,7 +128,7 @@ struct ge_mutable_reference_wrapper { ...@@ -128,7 +128,7 @@ struct ge_mutable_reference_wrapper {
template<typename T> template<typename T>
struct ge_reference_wrapper { struct ge_reference_wrapper {
T const* value; const T* value;
ge_reference_wrapper(T&&) = delete; ge_reference_wrapper(T&&) = delete;
ge_reference_wrapper() : value(nullptr) { } ge_reference_wrapper() : value(nullptr) { }
ge_reference_wrapper(const T& val_ref) : value(&val_ref) { } ge_reference_wrapper(const T& val_ref) : value(&val_ref) { }
...@@ -145,7 +145,7 @@ struct ge_reference_wrapper { ...@@ -145,7 +145,7 @@ struct ge_reference_wrapper {
// support use of gref(BooleanVariable) as receive loop 'guard' // support use of gref(BooleanVariable) as receive loop 'guard'
template<> template<>
struct ge_reference_wrapper<bool> { struct ge_reference_wrapper<bool> {
bool const* value; const bool* value;
ge_reference_wrapper(bool&&) = delete; ge_reference_wrapper(bool&&) = delete;
ge_reference_wrapper(const bool& val_ref) : value(&val_ref) { } ge_reference_wrapper(const bool& val_ref) : value(&val_ref) { }
ge_reference_wrapper(const ge_reference_wrapper&) = default; ge_reference_wrapper(const ge_reference_wrapper&) = default;
...@@ -470,8 +470,8 @@ struct ge_result_<guard_expr<OP, First, Second>, Tuple> { ...@@ -470,8 +470,8 @@ struct ge_result_<guard_expr<OP, First, Second>, Tuple> {
typedef typename ge_result_<First, Tuple>::type lhs_type; typedef typename ge_result_<First, Tuple>::type lhs_type;
typedef typename ge_result_<Second, Tuple>::type rhs_type; typedef typename ge_result_<Second, Tuple>::type rhs_type;
typedef decltype( typedef decltype(
ge_eval_op<OP>::_(*static_cast<lhs_type const*>(nullptr), ge_eval_op<OP>::_(*static_cast<const lhs_type*>(nullptr),
*static_cast<rhs_type const*>(nullptr))) type; *static_cast<const rhs_type*>(nullptr))) type;
}; };
template<typename Fun, class Tuple> template<typename Fun, class Tuple>
...@@ -483,8 +483,8 @@ template<typename First, typename Second, class Tuple> ...@@ -483,8 +483,8 @@ template<typename First, typename Second, class Tuple>
struct ge_result_<guard_expr<exec_fun1_op, First, Second>, Tuple> { struct ge_result_<guard_expr<exec_fun1_op, First, Second>, Tuple> {
typedef First type0; typedef First type0;
typedef typename ge_unbound<Second, Tuple>::type type1; typedef typename ge_unbound<Second, Tuple>::type type1;
typedef decltype( (*static_cast<type0 const*>(nullptr))( typedef decltype( (*static_cast<const type0*>(nullptr))(
*static_cast<type1 const*>(nullptr) *static_cast<const type1*>(nullptr)
)) type; )) type;
}; };
...@@ -493,9 +493,9 @@ struct ge_result_<guard_expr<exec_fun2_op, First, Second>, Tuple> { ...@@ -493,9 +493,9 @@ struct ge_result_<guard_expr<exec_fun2_op, First, Second>, Tuple> {
typedef typename First::first_type type0; typedef typename First::first_type type0;
typedef typename ge_unbound<typename First::second_type, Tuple>::type type1; typedef typename ge_unbound<typename First::second_type, Tuple>::type type1;
typedef typename ge_unbound<Second, Tuple>::type type2; typedef typename ge_unbound<Second, Tuple>::type type2;
typedef decltype( (*static_cast<type0 const*>(nullptr))( typedef decltype( (*static_cast<const type0*>(nullptr))(
*static_cast<type1 const*>(nullptr), *static_cast<const type1*>(nullptr),
*static_cast<type2 const*>(nullptr) *static_cast<const type2*>(nullptr)
)) type; )) type;
}; };
...@@ -505,10 +505,10 @@ struct ge_result_<guard_expr<exec_fun3_op, First, Second>, Tuple> { ...@@ -505,10 +505,10 @@ struct ge_result_<guard_expr<exec_fun3_op, First, Second>, Tuple> {
typedef typename ge_unbound<typename First::second_type,Tuple>::type type1; typedef typename ge_unbound<typename First::second_type,Tuple>::type type1;
typedef typename ge_unbound<typename Second::first_type,Tuple>::type type2; typedef typename ge_unbound<typename Second::first_type,Tuple>::type type2;
typedef typename ge_unbound<typename Second::second_type,Tuple>::type type3; typedef typename ge_unbound<typename Second::second_type,Tuple>::type type3;
typedef decltype( (*static_cast<type0 const*>(nullptr))( typedef decltype( (*static_cast<const type0*>(nullptr))(
*static_cast<type1 const*>(nullptr), *static_cast<const type1*>(nullptr),
*static_cast<type2 const*>(nullptr), *static_cast<const type2*>(nullptr),
*static_cast<type3 const*>(nullptr) *static_cast<const type3*>(nullptr)
)) type; )) type;
}; };
......
...@@ -47,7 +47,7 @@ class forward_iterator { ...@@ -47,7 +47,7 @@ class forward_iterator {
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef value_type* pointer; typedef value_type* pointer;
typedef value_type const* const_pointer; typedef const value_type* const_pointer;
typedef ptrdiff_t difference_type; typedef ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category; typedef std::forward_iterator_tag iterator_category;
...@@ -106,7 +106,7 @@ inline bool operator==(const forward_iterator<T>& lhs, ...@@ -106,7 +106,7 @@ inline bool operator==(const forward_iterator<T>& lhs,
* @relates forward_iterator * @relates forward_iterator
*/ */
template<class T> template<class T>
inline bool operator==(const forward_iterator<T>& lhs, T const* rhs) { inline bool operator==(const forward_iterator<T>& lhs, const T* rhs) {
return lhs.ptr() == rhs; return lhs.ptr() == rhs;
} }
...@@ -114,7 +114,7 @@ inline bool operator==(const forward_iterator<T>& lhs, T const* rhs) { ...@@ -114,7 +114,7 @@ inline bool operator==(const forward_iterator<T>& lhs, T const* rhs) {
* @relates forward_iterator * @relates forward_iterator
*/ */
template<class T> template<class T>
inline bool operator==(T const* lhs, const forward_iterator<T>& rhs) { inline bool operator==(const T* lhs, const forward_iterator<T>& rhs) {
return lhs == rhs.ptr(); return lhs == rhs.ptr();
} }
...@@ -147,7 +147,7 @@ inline bool operator!=(const forward_iterator<T>& lhs, ...@@ -147,7 +147,7 @@ inline bool operator!=(const forward_iterator<T>& lhs,
* @relates forward_iterator * @relates forward_iterator
*/ */
template<class T> template<class T>
inline bool operator!=(const forward_iterator<T>& lhs, T const* rhs) { inline bool operator!=(const forward_iterator<T>& lhs, const T* rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
...@@ -155,7 +155,7 @@ inline bool operator!=(const forward_iterator<T>& lhs, T const* rhs) { ...@@ -155,7 +155,7 @@ inline bool operator!=(const forward_iterator<T>& lhs, T const* rhs) {
* @relates forward_iterator * @relates forward_iterator
*/ */
template<class T> template<class T>
inline bool operator!=(T const* lhs, const forward_iterator<T>& rhs) { inline bool operator!=(const T* lhs, const forward_iterator<T>& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
} }
......
...@@ -58,7 +58,7 @@ class singly_linked_list { ...@@ -58,7 +58,7 @@ class singly_linked_list {
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef value_type* pointer; typedef value_type* pointer;
typedef value_type const* const_pointer; typedef const value_type* const_pointer;
typedef forward_iterator<value_type> iterator; typedef forward_iterator<value_type> iterator;
typedef forward_iterator<value_type const> const_iterator; typedef forward_iterator<value_type const> const_iterator;
......
...@@ -157,7 +157,7 @@ struct invoke_policy_impl<wildcard_position::nil, ...@@ -157,7 +157,7 @@ struct invoke_policy_impl<wildcard_position::nil,
if (native_arg) { if (native_arg) {
typedef typename util::if_else_c< typedef typename util::if_else_c<
std::is_const<PtrType>::value, std::is_const<PtrType>::value,
native_data_type const*, const native_data_type*,
util::wrapped<native_data_type*> util::wrapped<native_data_type*>
>::type >::type
cast_type; cast_type;
...@@ -738,11 +738,11 @@ class match_expr { ...@@ -738,11 +738,11 @@ class match_expr {
static constexpr size_t cache_size = 10; static constexpr size_t cache_size = 10;
//typedef std::array<bool, eval_order::size> cache_entry; //typedef std::array<bool, eval_order::size> cache_entry;
//typedef typename cache_entry::iterator cache_entry_iterator; //typedef typename cache_entry::iterator cache_entry_iterator;
//typedef std::pair<std::type_info const*, cache_entry> cache_element; //typedef std::pair<const std::type_info*, cache_entry> cache_element;
// std::uint64_t is used as a bitmask to enable/disable groups // std::uint64_t is used as a bitmask to enable/disable groups
typedef std::pair<std::type_info const*, std::uint64_t> cache_element; typedef std::pair<const std::type_info*, std::uint64_t> cache_element;
util::fixed_vector<cache_element, cache_size> m_cache; util::fixed_vector<cache_element, cache_size> m_cache;
...@@ -756,7 +756,7 @@ class match_expr { ...@@ -756,7 +756,7 @@ class match_expr {
i = (i + 1) % cache_size; i = (i + 1) % cache_size;
} }
inline size_t find_token_pos(std::type_info const* type_token) { inline size_t find_token_pos(const std::type_info* type_token) {
for (size_t i = m_cache_begin ; i != m_cache_end; advance_(i)) { for (size_t i = m_cache_begin ; i != m_cache_end; advance_(i)) {
if (m_cache[i].first == type_token) return i; if (m_cache[i].first == type_token) return i;
} }
...@@ -764,7 +764,7 @@ class match_expr { ...@@ -764,7 +764,7 @@ class match_expr {
} }
template<class Tuple> template<class Tuple>
std::uint64_t get_cache_entry(std::type_info const* type_token, std::uint64_t get_cache_entry(const std::type_info* type_token,
const Tuple& value) { const Tuple& value) {
CPPA_REQUIRE(type_token != nullptr); CPPA_REQUIRE(type_token != nullptr);
if (value.impl_type() == detail::dynamically_typed) { if (value.impl_type() == detail::dynamically_typed) {
...@@ -795,7 +795,7 @@ class match_expr { ...@@ -795,7 +795,7 @@ class match_expr {
template<typename AbstractTuple, typename NativeDataPtr> template<typename AbstractTuple, typename NativeDataPtr>
bool _do_invoke(AbstractTuple& vals, NativeDataPtr ndp) { bool _do_invoke(AbstractTuple& vals, NativeDataPtr ndp) {
std::type_info const* type_token = vals.type_token(); const std::type_info* type_token = vals.type_token();
auto bitfield = get_cache_entry(type_token, vals); auto bitfield = get_cache_entry(type_token, vals);
eval_order token; eval_order token;
detail::invoke_helper<decltype(m_cases)> fun{m_cases, bitfield}; detail::invoke_helper<decltype(m_cases)> fun{m_cases, bitfield};
......
...@@ -47,7 +47,7 @@ class object; ...@@ -47,7 +47,7 @@ class object;
bool operator==(const object& lhs, const object& rhs); bool operator==(const object& lhs, const object& rhs);
class uniform_type_info; class uniform_type_info;
uniform_type_info const* uniform_typeid(const std::type_info&); const uniform_type_info* uniform_typeid(const std::type_info&);
bool operator==(const uniform_type_info& lhs, const std::type_info& rhs); bool operator==(const uniform_type_info& lhs, const std::type_info& rhs);
/** /**
...@@ -87,7 +87,7 @@ class object { ...@@ -87,7 +87,7 @@ class object {
* @warning {@link object} takes ownership of @p val. * @warning {@link object} takes ownership of @p val.
* @pre {@code val != nullptr && utinfo != nullptr} * @pre {@code val != nullptr && utinfo != nullptr}
*/ */
object(void* val, uniform_type_info const* utinfo); object(void* val, const uniform_type_info* utinfo);
/** /**
* @brief Creates an empty object. * @brief Creates an empty object.
...@@ -124,7 +124,7 @@ class object { ...@@ -124,7 +124,7 @@ class object {
* @returns A {@link uniform_type_info} describing the current * @returns A {@link uniform_type_info} describing the current
* type of @p this. * type of @p this.
*/ */
uniform_type_info const* type() const; const uniform_type_info* type() const;
/** /**
* @brief Gets the stored value. * @brief Gets the stored value.
...@@ -153,7 +153,7 @@ class object { ...@@ -153,7 +153,7 @@ class object {
private: private:
void* m_value; void* m_value;
uniform_type_info const* m_type; const uniform_type_info* m_type;
void swap(object& other); void swap(object& other);
...@@ -188,7 +188,7 @@ const T& get(const object& obj) { ...@@ -188,7 +188,7 @@ const T& get(const object& obj) {
if (!(*(obj.type()) == typeid(T))) { if (!(*(obj.type()) == typeid(T))) {
throw std::invalid_argument("obj.type() != typeid(T)"); throw std::invalid_argument("obj.type() != typeid(T)");
} }
return *reinterpret_cast<T const*>(obj.value()); return *reinterpret_cast<const T*>(obj.value());
} }
} // namespace cppa } // namespace cppa
......
...@@ -241,7 +241,7 @@ class pattern { ...@@ -241,7 +241,7 @@ class pattern {
typedef util::fixed_vector<size_t, filtered_types::size> mapping_vector; typedef util::fixed_vector<size_t, filtered_types::size> mapping_vector;
typedef uniform_type_info const* const_iterator; typedef const uniform_type_info* const_iterator;
typedef std::reverse_iterator<const_iterator> reverse_const_iterator; typedef std::reverse_iterator<const_iterator> reverse_const_iterator;
......
...@@ -59,7 +59,7 @@ enum primitive_type { ...@@ -59,7 +59,7 @@ enum primitive_type {
pt_null /**< equivalent of @p void */ pt_null /**< equivalent of @p void */
}; };
constexpr char const* primitive_type_names[] = { constexpr const char* primitive_type_names[] = {
"pt_int8", "pt_int16", "pt_int32", "pt_int64", "pt_int8", "pt_int16", "pt_int32", "pt_int64",
"pt_uint8", "pt_uint16", "pt_uint32", "pt_uint64", "pt_uint8", "pt_uint16", "pt_uint32", "pt_uint64",
"pt_float", "pt_double", "pt_long_double", "pt_float", "pt_double", "pt_long_double",
...@@ -73,7 +73,7 @@ constexpr char const* primitive_type_names[] = { ...@@ -73,7 +73,7 @@ constexpr char const* primitive_type_names[] = {
* @param ptype Requestet @p primitive_type. * @param ptype Requestet @p primitive_type.
* @returns A C-string representation of @p ptype. * @returns A C-string representation of @p ptype.
*/ */
constexpr char const* primitive_type_name(primitive_type ptype) { constexpr const char* primitive_type_name(primitive_type ptype) {
return primitive_type_names[static_cast<int>(ptype)]; return primitive_type_names[static_cast<int>(ptype)];
} }
......
...@@ -90,7 +90,7 @@ class serializer { ...@@ -90,7 +90,7 @@ class serializer {
* @param num Size of the array @p values. * @param num Size of the array @p values.
* @param values An array of size @p num of primitive data values. * @param values An array of size @p num of primitive data values.
*/ */
virtual void write_tuple(size_t num, primitive_variant const* values) = 0; virtual void write_tuple(size_t num, const primitive_variant* values) = 0;
}; };
......
...@@ -38,7 +38,7 @@ namespace cppa { ...@@ -38,7 +38,7 @@ namespace cppa {
namespace detail { namespace detail {
std::string to_string_impl(const void* what, uniform_type_info const* utype); std::string to_string_impl(const void* what, const uniform_type_info* utype);
} // namespace detail } // namespace detail
......
...@@ -37,23 +37,23 @@ ...@@ -37,23 +37,23 @@
namespace cppa { namespace cppa {
typedef std::pair<uniform_type_info const*, const void*> type_value_pair; typedef std::pair<const uniform_type_info*, const void*> type_value_pair;
class type_value_pair_const_iterator { class type_value_pair_const_iterator {
type_value_pair const* iter; const type_value_pair* iter;
public: public:
typedef type_value_pair const value_type; typedef type_value_pair const value_type;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
typedef type_value_pair const* pointer; typedef const type_value_pair* pointer;
typedef const type_value_pair& reference; typedef const type_value_pair& reference;
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
constexpr type_value_pair_const_iterator() : iter(nullptr) { } constexpr type_value_pair_const_iterator() : iter(nullptr) { }
type_value_pair_const_iterator(type_value_pair const* i) : iter(i) { } type_value_pair_const_iterator(const type_value_pair* i) : iter(i) { }
type_value_pair_const_iterator(const type_value_pair_const_iterator&) type_value_pair_const_iterator(const type_value_pair_const_iterator&)
= default; = default;
...@@ -61,7 +61,7 @@ class type_value_pair_const_iterator { ...@@ -61,7 +61,7 @@ class type_value_pair_const_iterator {
type_value_pair_const_iterator& type_value_pair_const_iterator&
operator=(const type_value_pair_const_iterator&) = default; operator=(const type_value_pair_const_iterator&) = default;
inline uniform_type_info const* type() const { return iter->first; } inline const uniform_type_info* type() const { return iter->first; }
inline const void* value() const { return iter->second; } inline const void* value() const { return iter->second; }
......
...@@ -52,7 +52,7 @@ class serializer; ...@@ -52,7 +52,7 @@ class serializer;
class deserializer; class deserializer;
class uniform_type_info; class uniform_type_info;
uniform_type_info const* uniform_typeid(const std::type_info&); const uniform_type_info* uniform_typeid(const std::type_info&);
/** /**
* @defgroup TypeSystem libcppa's platform-independent type system. * @defgroup TypeSystem libcppa's platform-independent type system.
...@@ -178,7 +178,7 @@ class uniform_type_info { ...@@ -178,7 +178,7 @@ class uniform_type_info {
* @returns An instance describing the same type as @p tinfo. * @returns An instance describing the same type as @p tinfo.
* @throws std::runtime_error if @p tinfo is not an announced type. * @throws std::runtime_error if @p tinfo is not an announced type.
*/ */
static uniform_type_info const* from(const std::type_info& tinfo); static const uniform_type_info* from(const std::type_info& tinfo);
/** /**
* @brief Get all instances. * @brief Get all instances.
...@@ -266,7 +266,7 @@ class uniform_type_info { ...@@ -266,7 +266,7 @@ class uniform_type_info {
* @relates uniform_type_info * @relates uniform_type_info
*/ */
template<typename T> template<typename T>
inline uniform_type_info const* uniform_typeid() { inline const uniform_type_info* uniform_typeid() {
return uniform_typeid(typeid(T)); return uniform_typeid(typeid(T));
} }
......
...@@ -44,7 +44,7 @@ template<typename T> ...@@ -44,7 +44,7 @@ template<typename T>
class abstract_uniform_type_info : public uniform_type_info { class abstract_uniform_type_info : public uniform_type_info {
inline static const T& deref(const void* ptr) { inline static const T& deref(const void* ptr) {
return *reinterpret_cast<T const*>(ptr); return *reinterpret_cast<const T*>(ptr);
} }
inline static T& deref(void* ptr) { inline static T& deref(void* ptr) {
......
...@@ -66,10 +66,10 @@ class fixed_vector { ...@@ -66,10 +66,10 @@ class fixed_vector {
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef value_type* pointer; typedef value_type* pointer;
typedef value_type const* const_pointer; typedef const value_type* const_pointer;
typedef T* iterator; typedef T* iterator;
typedef T const* const_iterator; typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
...@@ -236,7 +236,7 @@ class fixed_vector { ...@@ -236,7 +236,7 @@ class fixed_vector {
return m_data; return m_data;
} }
inline T const* data() const { inline const T* data() const {
return m_data; return m_data;
} }
......
...@@ -47,13 +47,13 @@ class is_comparable { ...@@ -47,13 +47,13 @@ class is_comparable {
// candidate and thus decltype(cmp_help_fun(...)) is void. // candidate and thus decltype(cmp_help_fun(...)) is void.
template<typename A, typename B> template<typename A, typename B>
static bool cmp_help_fun(A const* arg0, B const* arg1, static bool cmp_help_fun(const A* arg0, const B* arg1,
decltype(*arg0 == *arg1)* = nullptr) { decltype(*arg0 == *arg1)* = nullptr) {
return true; return true;
} }
template<typename A, typename B> template<typename A, typename B>
static void cmp_help_fun(A const*, B const*, void* = nullptr) { } static void cmp_help_fun(const A*, const B*, void* = nullptr) { }
typedef decltype(cmp_help_fun(static_cast<T1*>(nullptr), typedef decltype(cmp_help_fun(static_cast<T1*>(nullptr),
static_cast<T2*>(nullptr), static_cast<T2*>(nullptr),
......
...@@ -47,7 +47,7 @@ class is_iterable { ...@@ -47,7 +47,7 @@ class is_iterable {
// this horrible code would just disappear if we had concepts // this horrible code would just disappear if we had concepts
template<class C> template<class C>
static bool sfinae_fun ( static bool sfinae_fun (
C const* cc, const C* cc,
// check for 'C::begin()' returning a forward iterator // check for 'C::begin()' returning a forward iterator
typename std::enable_if<util::is_forward_iterator<decltype(cc->begin())>::value>::type* = 0, typename std::enable_if<util::is_forward_iterator<decltype(cc->begin())>::value>::type* = 0,
// check for 'C::end()' returning the same kind of forward iterator // check for 'C::end()' returning the same kind of forward iterator
...@@ -59,7 +59,7 @@ class is_iterable { ...@@ -59,7 +59,7 @@ class is_iterable {
// SFNINAE default // SFNINAE default
static void sfinae_fun(const void*) { } static void sfinae_fun(const void*) { }
typedef decltype(sfinae_fun(static_cast<T const*>(nullptr))) result_type; typedef decltype(sfinae_fun(static_cast<const T*>(nullptr))) result_type;
public: public:
......
...@@ -85,7 +85,7 @@ class producer_consumer_list { ...@@ -85,7 +85,7 @@ class producer_consumer_list {
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef value_type* pointer; typedef value_type* pointer;
typedef value_type const* const_pointer; typedef const value_type* const_pointer;
struct node { struct node {
pointer value; pointer value;
......
...@@ -43,7 +43,7 @@ namespace cppa { ...@@ -43,7 +43,7 @@ namespace cppa {
// forward declarations // forward declarations
class uniform_type_info; class uniform_type_info;
uniform_type_info const* uniform_typeid(const std::type_info&); const uniform_type_info* uniform_typeid(const std::type_info&);
} // namespace cppa } // namespace cppa
......
...@@ -43,7 +43,7 @@ abstract_tuple::abstract_tuple(const abstract_tuple& other) ...@@ -43,7 +43,7 @@ abstract_tuple::abstract_tuple(const abstract_tuple& other)
, m_impl_type(other.m_impl_type) { , m_impl_type(other.m_impl_type) {
} }
std::type_info const* abstract_tuple::type_token() const { const std::type_info* abstract_tuple::type_token() const {
return &typeid(void); return &typeid(void);
} }
......
...@@ -106,8 +106,8 @@ bool actor_proxy_cache::erase(const actor_proxy_ptr& pptr) { ...@@ -106,8 +106,8 @@ bool actor_proxy_cache::erase(const actor_proxy_ptr& pptr) {
bool actor_proxy_cache::key_tuple_less::operator()(const key_tuple& lhs, bool actor_proxy_cache::key_tuple_less::operator()(const key_tuple& lhs,
const key_tuple& rhs) const { const key_tuple& rhs) const {
int cmp_res = strncmp(reinterpret_cast<char const*>(std::get<0>(lhs).data()), int cmp_res = strncmp(reinterpret_cast<const char*>(std::get<0>(lhs).data()),
reinterpret_cast<char const*>(std::get<0>(rhs).data()), reinterpret_cast<const char*>(std::get<0>(rhs).data()),
process_information::node_id_size); process_information::node_id_size);
if (cmp_res < 0) { if (cmp_res < 0) {
return true; return true;
......
...@@ -187,11 +187,11 @@ size_t binary_serializer::size() const { ...@@ -187,11 +187,11 @@ size_t binary_serializer::size() const {
return sendable_size() - ui32_size; return sendable_size() - ui32_size;
} }
char const* binary_serializer::data() const { const char* binary_serializer::data() const {
return m_begin + ui32_size; return m_begin + ui32_size;
} }
char const* binary_serializer::sendable_data() { const char* binary_serializer::sendable_data() {
auto s = static_cast<std::uint32_t>(size()); auto s = static_cast<std::uint32_t>(size());
memcpy(m_begin, &s, ui32_size); memcpy(m_begin, &s, ui32_size);
return m_begin; return m_begin;
......
...@@ -57,10 +57,10 @@ void converted_thread_context::enqueue(actor* sender, any_tuple msg) { ...@@ -57,10 +57,10 @@ void converted_thread_context::enqueue(actor* sender, any_tuple msg) {
} }
void converted_thread_context::dequeue(partial_function& fun) { // override void converted_thread_context::dequeue(partial_function& fun) { // override
if (invoke_from_cache(fun) == false) { if (m_recv_policy.invoke_from_cache(this, fun) == false) {
recursive_queue_node* e = m_mailbox.pop(); recursive_queue_node* e = m_mailbox.pop();
CPPA_REQUIRE(e->marked == false); CPPA_REQUIRE(e->marked == false);
while (invoke(e, fun) == false) { while (m_recv_policy.invoke(this, e, fun) == false) {
e = m_mailbox.pop(); e = m_mailbox.pop();
} }
} }
...@@ -72,11 +72,11 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override ...@@ -72,11 +72,11 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override
// suppress virtual function call // suppress virtual function call
converted_thread_context::dequeue(fun); converted_thread_context::dequeue(fun);
} }
else if (invoke_from_cache(fun) == false) { else if (m_recv_policy.invoke_from_cache(this, fun) == false) {
if (bhvr.timeout().is_zero()) { if (bhvr.timeout().is_zero()) {
for (auto e = m_mailbox.try_pop(); e != nullptr; e = m_mailbox.try_pop()) { for (auto e = m_mailbox.try_pop(); e != nullptr; e = m_mailbox.try_pop()) {
CPPA_REQUIRE(e->marked == false); CPPA_REQUIRE(e->marked == false);
if (invoke(e, bhvr)) return; if (m_recv_policy.invoke(this, e, bhvr)) return;
e = m_mailbox.try_pop(); e = m_mailbox.try_pop();
} }
bhvr.handle_timeout(); bhvr.handle_timeout();
...@@ -87,7 +87,7 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override ...@@ -87,7 +87,7 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override
recursive_queue_node* e = m_mailbox.try_pop(timeout); recursive_queue_node* e = m_mailbox.try_pop(timeout);
while (e != nullptr) { while (e != nullptr) {
CPPA_REQUIRE(e->marked == false); CPPA_REQUIRE(e->marked == false);
if (invoke(e, fun)) return; if (m_recv_policy.invoke(this, e, fun)) return;
e = m_mailbox.try_pop(timeout); e = m_mailbox.try_pop(timeout);
} }
bhvr.handle_timeout(); bhvr.handle_timeout();
...@@ -97,18 +97,17 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override ...@@ -97,18 +97,17 @@ void converted_thread_context::dequeue(behavior& bhvr) { // override
filter_result converted_thread_context::filter_msg(const any_tuple& msg) { filter_result converted_thread_context::filter_msg(const any_tuple& msg) {
auto& arr = detail::static_types_array<atom_value, std::uint32_t>::arr; auto& arr = detail::static_types_array<atom_value, std::uint32_t>::arr;
if ( msg.size() == 2 if ( m_trap_exit == false
&& msg.size() == 2
&& msg.type_at(0) == arr[0] && msg.type_at(0) == arr[0]
&& msg.type_at(1) == arr[1]) { && msg.type_at(1) == arr[1]) {
auto v0 = *reinterpret_cast<const atom_value*>(msg.at(0)); auto v0 = msg.get_as<atom_value>(0);
auto v1 = *reinterpret_cast<const std::uint32_t*>(msg.at(1)); auto v1 = msg.get_as<std::uint32_t>(1);
if (v0 == atom("EXIT")) { if (v0 == atom("EXIT")) {
if (this->m_trap_exit == false) { if (v1 != exit_reason::normal) {
if (v1 != exit_reason::normal) { quit(v1);
quit(v1);
}
return normal_exit_signal;
} }
return normal_exit_signal;
} }
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
namespace cppa { namespace detail { namespace cppa { namespace detail {
std::string demangle(char const* decorated) { std::string demangle(const char* decorated) {
size_t size; size_t size;
int status; int status;
char* undecorated = abi::__cxa_demangle(decorated, nullptr, &size, &status); char* undecorated = abi::__cxa_demangle(decorated, nullptr, &size, &status);
...@@ -52,7 +52,7 @@ std::string demangle(char const* decorated) { ...@@ -52,7 +52,7 @@ std::string demangle(char const* decorated) {
} }
std::string result; // the undecorated typeid name std::string result; // the undecorated typeid name
result.reserve(size); result.reserve(size);
char const* cstr = undecorated; const char* cstr = undecorated;
// filter unnecessary characters from undecorated // filter unnecessary characters from undecorated
char c = *cstr; char c = *cstr;
while (c != '\0') { while (c != '\0') {
......
...@@ -60,7 +60,7 @@ bool empty_tuple::equals(const abstract_tuple& other) const { ...@@ -60,7 +60,7 @@ bool empty_tuple::equals(const abstract_tuple& other) const {
return other.size() == 0; return other.size() == 0;
} }
std::type_info const* empty_tuple::type_token() const { const std::type_info* empty_tuple::type_token() const {
return &typeid(util::type_list<>); return &typeid(util::type_list<>);
} }
......
...@@ -41,7 +41,7 @@ namespace { ...@@ -41,7 +41,7 @@ namespace {
cppa::util::void_type s_void; cppa::util::void_type s_void;
inline cppa::uniform_type_info const* tvoid() { inline const cppa::uniform_type_info* tvoid() {
return cppa::detail::static_types_array<cppa::util::void_type>::arr[0]; return cppa::detail::static_types_array<cppa::util::void_type>::arr[0];
} }
...@@ -54,7 +54,7 @@ void object::swap(object& other) { ...@@ -54,7 +54,7 @@ void object::swap(object& other) {
std::swap(m_type, other.m_type); std::swap(m_type, other.m_type);
} }
object::object(void* val, uniform_type_info const* utype) object::object(void* val, const uniform_type_info* utype)
: m_value(val), m_type(utype) { : m_value(val), m_type(utype) {
CPPA_REQUIRE(val != nullptr); CPPA_REQUIRE(val != nullptr);
CPPA_REQUIRE(utype != nullptr); CPPA_REQUIRE(utype != nullptr);
...@@ -98,7 +98,7 @@ bool operator==(const object& lhs, const object& rhs) { ...@@ -98,7 +98,7 @@ bool operator==(const object& lhs, const object& rhs) {
return false; return false;
} }
uniform_type_info const* object::type() const { const uniform_type_info* object::type() const {
return m_type; return m_type;
} }
......
...@@ -59,7 +59,7 @@ const void* object_array::at(size_t pos) const { ...@@ -59,7 +59,7 @@ const void* object_array::at(size_t pos) const {
return m_elements[pos].value(); return m_elements[pos].value();
} }
uniform_type_info const* object_array::type_at(size_t pos) const { const uniform_type_info* object_array::type_at(size_t pos) const {
return m_elements[pos].type(); return m_elements[pos].type();
} }
......
...@@ -169,7 +169,7 @@ class po_peer : public po_socket_handler { ...@@ -169,7 +169,7 @@ class po_peer : public po_socket_handler {
// the process information of our remote peer // the process information of our remote peer
process_information_ptr m_peer; process_information_ptr m_peer;
// caches uniform_typeid<addressed_message>() // caches uniform_typeid<addressed_message>()
uniform_type_info const* m_meta_msg; const uniform_type_info* m_meta_msg;
// manages socket input // manages socket input
buffer<512, (16 * 1024 * 1024)> m_buf; buffer<512, (16 * 1024 * 1024)> m_buf;
......
...@@ -187,8 +187,8 @@ const intrusive_ptr<process_information>& process_information::get() { ...@@ -187,8 +187,8 @@ const intrusive_ptr<process_information>& process_information::get() {
} }
int process_information::compare(const process_information& other) const { int process_information::compare(const process_information& other) const {
int tmp = strncmp(reinterpret_cast<char const*>(node_id().data()), int tmp = strncmp(reinterpret_cast<const char*>(node_id().data()),
reinterpret_cast<char const*>(other.node_id().data()), reinterpret_cast<const char*>(other.node_id().data()),
node_id_size); node_id_size);
if (tmp == 0) { if (tmp == 0) {
if (m_process_id < other.process_id()) return -1; if (m_process_id < other.process_id()) return -1;
......
...@@ -143,10 +143,10 @@ void scheduler_helper::time_emitter(scheduler_helper::ptr_type m_self) { ...@@ -143,10 +143,10 @@ void scheduler_helper::time_emitter(scheduler_helper::ptr_type m_self) {
queue_node_ptr ptr{std::move(it->second)}; queue_node_ptr ptr{std::move(it->second)};
CPPA_REQUIRE(ptr->marked == false); CPPA_REQUIRE(ptr->marked == false);
auto whom = const_cast<actor_ptr*>( auto whom = const_cast<actor_ptr*>(
reinterpret_cast<actor_ptr const*>( reinterpret_cast<const actor_ptr*>(
ptr->msg.at(1))); ptr->msg.at(1)));
if (*whom) { if (*whom) {
any_tuple msg = *(reinterpret_cast<any_tuple const*>( any_tuple msg = *(reinterpret_cast<const any_tuple*>(
ptr->msg.at(2))); (*whom)->enqueue(ptr->sender.get(), std::move(msg)); ptr->msg.at(2))); (*whom)->enqueue(ptr->sender.get(), std::move(msg));
} }
messages.erase(it); messages.erase(it);
......
...@@ -521,7 +521,7 @@ class process_info_ptr_tinfo : public util::abstract_uniform_type_info<process_i ...@@ -521,7 +521,7 @@ class process_info_ptr_tinfo : public util::abstract_uniform_type_info<process_i
public: public:
virtual void serialize(const void* instance, serializer* sink) const { virtual void serialize(const void* instance, serializer* sink) const {
auto& ptr = *reinterpret_cast<ptr_type const*>(instance); auto& ptr = *reinterpret_cast<const ptr_type*>(instance);
if (ptr == nullptr) { if (ptr == nullptr) {
serialize_nullptr(sink); serialize_nullptr(sink);
} }
......
...@@ -40,28 +40,32 @@ ...@@ -40,28 +40,32 @@
namespace cppa { namespace detail { namespace cppa { namespace detail {
yielding_actor::yielding_actor(std::function<void()> fun) yielding_actor::yielding_actor(std::function<void()> fun)
: m_fiber(&yielding_actor::run, this) : m_fiber(&yielding_actor::trampoline, this)
, m_behavior(fun) { , m_behavior(fun) {
} }
void yielding_actor::run(void* ptr_arg) { void yielding_actor::run() {
auto this_ptr = reinterpret_cast<yielding_actor*>(ptr_arg); CPPA_REQUIRE(static_cast<bool>(m_behavior));
CPPA_REQUIRE(static_cast<bool>(this_ptr->m_behavior));
bool cleanup_called = false; bool cleanup_called = false;
try { this_ptr->m_behavior(); } try { m_behavior(); }
catch (actor_exited&) { catch (actor_exited&) {
// cleanup already called by scheduled_actor::quit // cleanup already called by scheduled_actor::quit
cleanup_called = true; cleanup_called = true;
} }
catch (...) { catch (...) {
this_ptr->cleanup(exit_reason::unhandled_exception); cleanup(exit_reason::unhandled_exception);
cleanup_called = true; cleanup_called = true;
} }
if (!cleanup_called) this_ptr->cleanup(exit_reason::normal); if (!cleanup_called) cleanup(exit_reason::normal);
this_ptr->on_exit(); on_exit();
std::atomic_thread_fence(std::memory_order_seq_cst);
yield(yield_state::done); yield(yield_state::done);
} }
void yielding_actor::trampoline(void* ptr_arg) {
reinterpret_cast<yielding_actor*>(ptr_arg)->run();
}
void yielding_actor::yield_until_not_empty() { void yielding_actor::yield_until_not_empty() {
if (m_mailbox.can_fetch_more() == false) { if (m_mailbox.can_fetch_more() == false) {
m_state.store(abstract_scheduled_actor::about_to_block); m_state.store(abstract_scheduled_actor::about_to_block);
...@@ -79,8 +83,8 @@ void yielding_actor::yield_until_not_empty() { ...@@ -79,8 +83,8 @@ void yielding_actor::yield_until_not_empty() {
} }
void yielding_actor::dequeue(partial_function& fun) { void yielding_actor::dequeue(partial_function& fun) {
if (invoke_from_cache(fun) == false) { if (m_recv_policy.invoke_from_cache(this, fun) == false) {
while (invoke(receive_node(), fun) == false) { } while (m_recv_policy.invoke(this, receive_node(), fun) == false) { }
} }
} }
...@@ -89,17 +93,17 @@ void yielding_actor::dequeue(behavior& bhvr) { ...@@ -89,17 +93,17 @@ void yielding_actor::dequeue(behavior& bhvr) {
// suppress virtual function call // suppress virtual function call
yielding_actor::dequeue(bhvr.get_partial_function()); yielding_actor::dequeue(bhvr.get_partial_function());
} }
else if (invoke_from_cache(bhvr) == false) { else if (m_recv_policy.invoke_from_cache(this, bhvr) == false) {
if (bhvr.timeout().is_zero()) { if (bhvr.timeout().is_zero()) {
for (auto e = m_mailbox.try_pop(); e != nullptr; e = m_mailbox.try_pop()) { for (auto e = m_mailbox.try_pop(); e != nullptr; e = m_mailbox.try_pop()) {
CPPA_REQUIRE(e->marked == false); CPPA_REQUIRE(e->marked == false);
if (invoke(e, bhvr)) return; if (m_recv_policy.invoke(this, e, bhvr)) return;
} }
bhvr.handle_timeout(); bhvr.handle_timeout();
} }
else { else {
request_timeout(bhvr.timeout()); request_timeout(bhvr.timeout());
while (invoke(receive_node(), bhvr) == false) { } while (m_recv_policy.invoke(this, receive_node(), bhvr) == false) { }
} }
} }
} }
......
...@@ -102,7 +102,7 @@ std::vector<string_pair> get_kv_pairs(int argc, char** argv, int begin = 1) { ...@@ -102,7 +102,7 @@ std::vector<string_pair> get_kv_pairs(int argc, char** argv, int begin = 1) {
return result; return result;
} }
void usage(char const* argv0) { void usage(const char* argv0) {
cout << "usage: " << split(argv0, '/').back() << " " cout << "usage: " << split(argv0, '/').back() << " "
<< "[run=remote_actor] " << "[run=remote_actor] "
<< "[scheduler=(thread_pool_scheduler|mock_scheduler)]" << "[scheduler=(thread_pool_scheduler|mock_scheduler)]"
...@@ -117,7 +117,7 @@ int main(int argc, char** argv) { ...@@ -117,7 +117,7 @@ int main(int argc, char** argv) {
} }
); );
match_each(argv + 1, argv + argc, [](char const* cstr) { return split(cstr, '='); }) ( match_each(argv + 1, argv + argc, [](const char* cstr) { return split(cstr, '='); }) (
on_arg_match >> [](const std::string& key, const std::string& value) { on_arg_match >> [](const std::string& key, const std::string& value) {
cout << "key = \"" << key << "\", value = \"" << value << "\"" cout << "key = \"" << key << "\", value = \"" << value << "\""
<< endl; << endl;
......
...@@ -28,7 +28,7 @@ inline bool cppa_check_value_fun_eq(T1 value1, T2 value2, ...@@ -28,7 +28,7 @@ inline bool cppa_check_value_fun_eq(T1 value1, T2 value2,
template<typename T1, typename T2> template<typename T1, typename T2>
inline bool cppa_check_value_fun(const T1& value1, const T2& value2, inline bool cppa_check_value_fun(const T1& value1, const T2& value2,
char const* file_name, const char* file_name,
int line_number, int line_number,
size_t& error_count) { size_t& error_count) {
if (cppa_check_value_fun_eq(value1, value2) == false) { if (cppa_check_value_fun_eq(value1, value2) == false) {
...@@ -44,7 +44,7 @@ inline bool cppa_check_value_fun(const T1& value1, const T2& value2, ...@@ -44,7 +44,7 @@ inline bool cppa_check_value_fun(const T1& value1, const T2& value2,
template<typename T1, typename T2> template<typename T1, typename T2>
inline void cppa_check_value_verbose_fun(const T1& value1, const T2& value2, inline void cppa_check_value_verbose_fun(const T1& value1, const T2& value2,
char const* file_name, const char* file_name,
int line_number, int line_number,
size_t& error_count) { size_t& error_count) {
if (cppa_check_value_fun(value1, value2, file_name, if (cppa_check_value_fun(value1, value2, file_name,
...@@ -103,7 +103,7 @@ if (!(line_of_code)) { \ ...@@ -103,7 +103,7 @@ if (!(line_of_code)) { \
typedef std::pair<std::string, std::string> string_pair; typedef std::pair<std::string, std::string> string_pair;
size_t test__yield_interface(); size_t test__yield_interface();
size_t test__remote_actor(char const* app_path, bool is_client, size_t test__remote_actor(const char* app_path, bool is_client,
const std::vector<string_pair>& args); const std::vector<string_pair>& args);
size_t test__ripemd_160(); size_t test__ripemd_160();
size_t test__uniform_type(); size_t test__uniform_type();
......
...@@ -27,12 +27,12 @@ bool ascending(int a, int b, int c) { ...@@ -27,12 +27,12 @@ bool ascending(int a, int b, int c) {
return a < b && b < c; return a < b && b < c;
} }
vector<uniform_type_info const*> to_vec(util::type_list<>, vector<uniform_type_info const*> vec = vector<uniform_type_info const*>{}) { vector<const uniform_type_info*> to_vec(util::type_list<>, vector<const uniform_type_info*> vec = vector<const uniform_type_info*>{}) {
return vec; return vec;
} }
template<typename Head, typename... Tail> template<typename Head, typename... Tail>
vector<uniform_type_info const*> to_vec(util::type_list<Head, Tail...>, vector<uniform_type_info const*> vec = vector<uniform_type_info const*>{}) { vector<const uniform_type_info*> to_vec(util::type_list<Head, Tail...>, vector<const uniform_type_info*> vec = vector<const uniform_type_info*>{}) {
vec.push_back(uniform_typeid<Head>()); vec.push_back(uniform_typeid<Head>());
return to_vec(util::type_list<Tail...>{}, std::move(vec)); return to_vec(util::type_list<Tail...>{}, std::move(vec));
} }
......
...@@ -72,10 +72,10 @@ size_t test__pattern() { ...@@ -72,10 +72,10 @@ size_t test__pattern() {
announce<foobar>(&foobar::first, &foobar::second); announce<foobar>(&foobar::first, &foobar::second);
static constexpr char const* arr1_as_string = static constexpr const char* arr1_as_string =
"{ arr[0] = @i32, arr[1] = anything, arr[2] = float }"; "{ arr[0] = @i32, arr[1] = anything, arr[2] = float }";
CPPA_CHECK_EQUAL(arr1_as_string, plot(arr1)); CPPA_CHECK_EQUAL(arr1_as_string, plot(arr1));
static constexpr char const* arr2_as_string = static constexpr const char* arr2_as_string =
"{ arr[0] = @i32, arr[1] = anything, " "{ arr[0] = @i32, arr[1] = anything, "
"arr[2] = std::pair<@i32,@i32> }"; "arr[2] = std::pair<@i32,@i32> }";
CPPA_CHECK_EQUAL(arr2_as_string, plot(arr2)); CPPA_CHECK_EQUAL(arr2_as_string, plot(arr2));
......
...@@ -31,7 +31,7 @@ void client_part(const std::vector<string_pair>& args) { ...@@ -31,7 +31,7 @@ void client_part(const std::vector<string_pair>& args) {
} // namespace <anonymous> } // namespace <anonymous>
size_t test__remote_actor(char const* app_path, bool is_client, size_t test__remote_actor(const char* app_path, bool is_client,
const std::vector<string_pair>& args) { const std::vector<string_pair>& args) {
if (is_client) { if (is_client) {
client_part(args); client_part(args);
......
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