Commit 5b69972e authored by Dominik Charousset's avatar Dominik Charousset

maintenance & documentation

parent f5767cc0
......@@ -20,7 +20,7 @@ set(LIBCPPA_SRC
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/channel.cpp
src/converted_thread_context.cpp
src/thread_mapped_actor.cpp
src/cppa.cpp
src/demangle.cpp
src/deserializer.cpp
......@@ -31,7 +31,6 @@ set(LIBCPPA_SRC
src/fiber.cpp
src/group.cpp
src/group_manager.cpp
src/invokable.cpp
src/local_actor.cpp
src/mailman.cpp
src/mock_scheduler.cpp
......@@ -60,7 +59,7 @@ set(LIBCPPA_SRC
src/unicast_network.cpp
src/uniform_type_info.cpp
src/yield_interface.cpp
src/yielding_actor.cpp
src/context_switching_actor.cpp
)
set(boost_context third_party/boost_context/)
......
......@@ -51,7 +51,7 @@ struct testee : fsm_actor<testee> {
init_state = (
on(atom("spread"), 0) >> [=]() {
send(parent, atom("result"), (uint32_t) 1);
quit_normal();
quit();
},
on<atom("spread"), int>() >> [=](int x) {
any_tuple msg = make_cow_tuple(atom("spread"), x - 1);
......@@ -62,7 +62,7 @@ struct testee : fsm_actor<testee> {
become (
on<atom("result"), uint32_t>() >> [=](uint32_t r2) {
send(parent, atom("result"), r1 + r2);
quit_normal();
quit();
}
);
}
......
......@@ -134,7 +134,7 @@ struct ping_actor : fsm_actor<ping_actor> {
become (
on<atom("pong"), uint32_t>().when(_x2 == uint32_t(0)) >> [=]() {
send(parent, atom("done"));
quit_normal();
quit();
},
on(atom("pong"), arg_match) >> [=](uint32_t value) {
reply(atom("ping"), value - 1);
......@@ -206,7 +206,7 @@ struct server_actor : fsm_actor<server_actor> {
},
on(atom("shutdown")) >> [=]() {
m_pongs.clear();
quit_normal();
quit();
},
others() >> [=]() {
cout << "unexpected: " << to_string(last_dequeued()) << endl;
......
......@@ -53,7 +53,7 @@ struct fsm_receiver : fsm_actor<fsm_receiver> {
on(atom("msg")) >> [=]() {
++m_value;
if (m_value == max) {
quit_normal();
quit();
}
}
);
......
......@@ -39,7 +39,7 @@
#include "cppa/match.hpp"
#include "cppa/fsm_actor.hpp"
#include "cppa/detail/mock_scheduler.hpp"
#include "cppa/detail/yielding_actor.hpp"
#include "cppa/context_switching_actor.hpp"
using std::cout;
using std::cerr;
......@@ -73,7 +73,7 @@ struct fsm_worker : fsm_actor<fsm_worker> {
send(mc, atom("result"), factorize(what));
},
on(atom("done")) >> [=]() {
quit_normal();
quit();
}
);
}
......@@ -86,7 +86,7 @@ struct fsm_chain_link : fsm_actor<fsm_chain_link> {
init_state = (
on<atom("token"), int>() >> [=](int v) {
next << std::move(last_dequeued());
if (v == 0) quit_normal();
if (v == 0) quit();
}
);
}
......@@ -120,7 +120,7 @@ struct fsm_chain_master : fsm_actor<fsm_chain_master> {
else {
send(worker, atom("done"));
send(mc, atom("masterdone"));
quit_normal();
quit();
}
},
on<atom("token"), int>() >> [=](int v) {
......@@ -138,11 +138,11 @@ struct fsm_supervisor : fsm_actor<fsm_supervisor> {
fsm_supervisor(int num_msgs) : left(num_msgs) {
init_state = (
on(atom("masterdone")) >> [=]() {
if (--left == 0) quit_normal();
if (--left == 0) quit();
},
on<atom("result"), factors>() >> [=](const factors& vec) {
check_factors(vec);
if (--left == 0) quit_normal();
if (--left == 0) quit();
}
);
}
......
......@@ -46,7 +46,7 @@ cppa/detail/boxed.hpp
cppa/detail/buffer.hpp
cppa/detail/channel.hpp
cppa/detail/container_tuple_view.hpp
cppa/detail/converted_thread_context.hpp
cppa/thread_mapped_actor.hpp
cppa/detail/decorated_tuple.hpp
cppa/detail/default_uniform_type_info_impl.hpp
cppa/detail/demangle.hpp
......@@ -56,7 +56,6 @@ cppa/detail/filter_result.hpp
cppa/detail/get_behavior.hpp
cppa/detail/group_manager.hpp
cppa/detail/implicit_conversions.hpp
cppa/detail/invokable.hpp
cppa/detail/list_member.hpp
cppa/detail/mailman.hpp
cppa/detail/map_member.hpp
......@@ -92,7 +91,7 @@ cppa/detail/unboxed.hpp
cppa/detail/uniform_type_info_map.hpp
cppa/detail/value_guard.hpp
cppa/detail/yield_interface.hpp
cppa/detail/yielding_actor.hpp
cppa/context_switching_actor.hpp
cppa/either.hpp
cppa/event_based_actor.hpp
cppa/event_based_actor_base.hpp
......@@ -157,7 +156,6 @@ cppa/util/is_mutable_ref.hpp
cppa/util/is_primitive.hpp
cppa/util/left_or_right.hpp
cppa/util/producer_consumer_list.hpp
cppa/util/projection.hpp
cppa/util/pt_dispatch.hpp
cppa/util/pt_token.hpp
cppa/util/purge_refs.hpp
......@@ -206,7 +204,7 @@ src/attachable.cpp
src/binary_deserializer.cpp
src/binary_serializer.cpp
src/channel.cpp
src/converted_thread_context.cpp
src/thread_mapped_actor.cpp
src/cppa.cpp
src/demangle.cpp
src/deserializer.cpp
......@@ -217,7 +215,6 @@ src/exception.cpp
src/fiber.cpp
src/group.cpp
src/group_manager.cpp
src/invokable.cpp
src/local_actor.cpp
src/mailman.cpp
src/mock_scheduler.cpp
......@@ -246,7 +243,7 @@ src/to_uniform_name.cpp
src/unicast_network.cpp
src/uniform_type_info.cpp
src/yield_interface.cpp
src/yielding_actor.cpp
src/context_switching_actor.cpp
unit_testing/main.cpp
unit_testing/ping_pong.cpp
unit_testing/ping_pong.hpp
......
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ABSTRACT_ACTOR_HPP
#define ABSTRACT_ACTOR_HPP
#ifndef CPPA_ABSTRACT_ACTOR_HPP
#define CPPA_ABSTRACT_ACTOR_HPP
#include "cppa/config.hpp"
......@@ -275,4 +275,4 @@ class abstract_actor : public Base {
} // namespace cppa
#endif // ABSTRACT_ACTOR_HPP
#endif // CPPA_ABSTRACT_ACTOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef EVENT_DRIVEN_ACTOR_HPP
#define EVENT_DRIVEN_ACTOR_HPP
#ifndef CPPA_ABSTRACT_EVENT_BASED_ACTOR_HPP
#define CPPA_ABSTRACT_EVENT_BASED_ACTOR_HPP
#include <stack>
#include <memory>
......@@ -57,7 +57,7 @@ class abstract_event_based_actor : public detail::abstract_scheduled_actor {
void dequeue(partial_function&); //override
void resume(util::fiber*, scheduler::callback* cb); //override
resume_result resume(util::fiber*); //override
/**
* @brief Initializes the actor by defining an initial behavior.
......@@ -130,4 +130,4 @@ class abstract_event_based_actor : public detail::abstract_scheduled_actor {
} // namespace cppa
#endif // EVENT_DRIVEN_ACTOR_HPP
#endif // CPPA_ABSTRACT_EVENT_BASED_ACTOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ACTOR_HPP
#define ACTOR_HPP
#ifndef CPPA_ACTOR_HPP
#define CPPA_ACTOR_HPP
#include <memory>
#include <cstdint>
......@@ -283,4 +283,4 @@ bool actor::attach_functor(F&& ftor) {
} // namespace cppa
#endif // ACTOR_HPP
#endif // CPPA_ACTOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ACTOR_PROXY_HPP
#define ACTOR_PROXY_HPP
#ifndef CPPA_ACTOR_PROXY_HPP
#define CPPA_ACTOR_PROXY_HPP
#include "cppa/actor.hpp"
#include "cppa/abstract_actor.hpp"
......@@ -39,7 +39,7 @@ namespace cppa {
#ifdef CPPA_DOCUMENTATION
/**
* @brief Represents a remote Actor.
* @brief Represents a remote actor.
*/
class actor_proxy : public actor { };
......@@ -81,9 +81,10 @@ class actor_proxy : public abstract_actor<actor> {
/**
* @brief A smart pointer to an {@link actor_proxy} instance.
* @relates actor_proxy
*/
typedef intrusive_ptr<actor_proxy> actor_proxy_ptr;
} // namespace cppa
#endif // ACTOR_PROXY_HPP
#endif // CPPA_ACTOR_PROXY_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ANNOUNCE_HPP
#define ANNOUNCE_HPP
#ifndef CPPA_ANNOUNCE_HPP
#define CPPA_ANNOUNCE_HPP
#include <typeinfo>
......@@ -169,4 +169,4 @@ inline bool announce(const Args&... args) {
} // namespace cppa
#endif // ANNOUNCE_HPP
#endif // CPPA_ANNOUNCE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ANY_TUPLE_HPP
#define ANY_TUPLE_HPP
#ifndef CPPA_ANY_TUPLE_HPP
#define CPPA_ANY_TUPLE_HPP
#include <type_traits>
......@@ -268,4 +268,4 @@ inline any_tuple make_any_tuple(Args&&... args) {
} // namespace cppa
#endif // ANY_TUPLE_HPP
#endif // CPPA_ANY_TUPLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef LIBCPPA_ANYTHING_HPP
#define LIBCPPA_ANYTHING_HPP
#ifndef CPPA_ANYTHING_HPP
#define CPPA_ANYTHING_HPP
#include <type_traits>
......@@ -65,4 +65,4 @@ struct is_anything {
} // namespace cppa
#endif // ANYTHING_HPP
#endif // CPPA_ANYTHING_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ATOM_HPP
#define ATOM_HPP
#ifndef CPPA_ATOM_HPP
#define CPPA_ATOM_HPP
#include <string>
......@@ -63,4 +63,4 @@ constexpr atom_value atom(char const (&str) [Size]) {
} // namespace cppa
#endif // ATOM_HPP
#endif // CPPA_ATOM_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ATTACHABLE_HPP
#define ATTACHABLE_HPP
#ifndef CPPA_ATTACHABLE_HPP
#define CPPA_ATTACHABLE_HPP
#include <cstdint>
#include <typeinfo>
......@@ -88,4 +88,4 @@ class attachable {
} // namespace cppa
#endif // ATTACHABLE_HPP
#endif // CPPA_ATTACHABLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef BEHAVIOR_HPP
#define BEHAVIOR_HPP
#ifndef CPPA_BEHAVIOR_HPP
#define CPPA_BEHAVIOR_HPP
#include <functional>
#include <type_traits>
......@@ -175,4 +175,4 @@ struct select_bhvr {
} // namespace cppa
#endif // BEHAVIOR_HPP
#endif // CPPA_BEHAVIOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef BINARY_DESERIALIZER_HPP
#define BINARY_DESERIALIZER_HPP
#ifndef CPPA_BINARY_DESERIALIZER_HPP
#define CPPA_BINARY_DESERIALIZER_HPP
#include "cppa/deserializer.hpp"
......@@ -66,4 +66,4 @@ class binary_deserializer : public deserializer {
} // namespace cppa
#endif // BINARY_DESERIALIZER_HPP
#endif // CPPA_BINARY_DESERIALIZER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef BINARY_SERIALIZER_HPP
#define BINARY_SERIALIZER_HPP
#ifndef CPPA_BINARY_SERIALIZER_HPP
#define CPPA_BINARY_SERIALIZER_HPP
#include <utility>
#include "cppa/serializer.hpp"
......@@ -94,4 +94,4 @@ class binary_serializer : public serializer {
} // namespace cppa
#endif // BINARY_SERIALIZER_HPP
#endif // CPPA_BINARY_SERIALIZER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef CHANNEL_HPP
#define CHANNEL_HPP
#ifndef CPPA_CHANNEL_HPP
#define CPPA_CHANNEL_HPP
#include "cppa/ref_counted.hpp"
#include "cppa/intrusive_ptr.hpp"
......@@ -77,4 +77,4 @@ typedef intrusive_ptr<channel> channel_ptr;
} // namespace cppa
#endif // CHANNEL_HPP
#endif // CPPA_CHANNEL_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef YIELDING_ACTOR_HPP
#define YIELDING_ACTOR_HPP
#ifndef CPPA_CONTEXT_SWITCHING_ACTOR_HPP
#define CPPA_CONTEXT_SWITCHING_ACTOR_HPP
#include "cppa/config.hpp"
......@@ -44,50 +44,72 @@
#include "cppa/detail/nestable_receive_policy.hpp"
#include "cppa/detail/abstract_scheduled_actor.hpp"
namespace cppa { namespace detail {
namespace cppa {
class yielding_actor : public abstract_scheduled_actor {
#ifdef CPPA_DOCUMENTATION
friend class nestable_receive_policy;
/**
* @brief Context-switching actor implementation.
*/
class context_switching_actor : public scheduled_actor {
typedef abstract_scheduled_actor super;
protected:
/**
* @brief Implements the actor's behavior.
* Reimplemented this function for a class-based context-switching
* actor. Returning from this member function will end the
* execution of the actor.
*/
virtual void run();
};
#else
class context_switching_actor : public detail::abstract_scheduled_actor {
friend class detail::nestable_receive_policy;
typedef detail::abstract_scheduled_actor super;
public:
yielding_actor(std::function<void()> fun);
context_switching_actor(std::function<void()> fun);
void dequeue(behavior& bhvr); //override
void dequeue(partial_function& fun); //override
void resume(util::fiber* from, scheduler::callback* callback); //override
resume_result resume(util::fiber* from); //override
inline void push_timeout() {
++m_active_timeout_id;
}
protected:
inline void pop_timeout() {
--m_active_timeout_id;
}
context_switching_actor();
private:
virtual void run();
typedef std::unique_ptr<recursive_queue_node> queue_node_ptr;
private:
void run();
// required by detail::nestable_receive_policy
detail::recursive_queue_node* receive_node();
inline void push_timeout() { ++m_active_timeout_id; }
inline void pop_timeout() { --m_active_timeout_id; }
// required by util::fiber
static void trampoline(void* _this);
// members
util::fiber m_fiber;
std::function<void()> m_behavior;
nestable_receive_policy m_recv_policy;
recursive_queue_node* receive_node();
detail::nestable_receive_policy m_recv_policy;
};
} } // namespace cppa::detail
#endif // CPPA_DOCUMENTATION
} // namespace cppa
#endif // CPPA_DISABLE_CONTEXT_SWITCHING
#endif // YIELDING_ACTOR_HPP
#endif // CPPA_CONTEXT_SWITCHING_ACTOR_HPP
......@@ -28,13 +28,15 @@
\******************************************************************************/
#ifndef COW_PTR_HPP
#define COW_PTR_HPP
#ifndef CPPA_COW_PTR_HPP
#define CPPA_COW_PTR_HPP
#include <cstddef>
#include <stdexcept>
#include <type_traits>
#include "cppa/intrusive_ptr.hpp"
#include "cppa/util/comparable.hpp"
namespace cppa {
......@@ -46,83 +48,93 @@ namespace cppa {
* {@link ref_counted}.
*/
template<typename T>
class cow_ptr {
class cow_ptr : util::comparable<cow_ptr<T> >,
util::comparable<cow_ptr<T>, const T*>,
util::comparable<cow_ptr<T>, std::nullptr_t> {
public:
template<typename Y>
explicit cow_ptr(Y* raw_ptr) : m_ptr(raw_ptr) { }
typedef T* pointer;
typedef const T* const_pointer;
typedef T element_type;
typedef T& reference;
typedef const T& const_reference;
explicit cow_ptr(T* raw_ptr) : m_ptr(raw_ptr) { }
constexpr cow_ptr() : m_ptr() { }
cow_ptr(cow_ptr&& other) : m_ptr(std::move(other.m_ptr)) { }
cow_ptr(pointer raw_ptr) : m_ptr(raw_ptr) { }
cow_ptr(const cow_ptr& other) : m_ptr(other.m_ptr) { }
cow_ptr(cow_ptr&&) = default;
cow_ptr(const cow_ptr&) = default;
cow_ptr& operator=(cow_ptr&&) = default;
cow_ptr& operator=(const cow_ptr&) = default;
template<typename Y>
cow_ptr(const cow_ptr<Y>& other) : m_ptr(const_cast<Y*>(other.get())) { }
inline void swap(cow_ptr& other) {
m_ptr.swap(other.m_ptr);
cow_ptr(cow_ptr<Y> other) : m_ptr(other.m_ptr.release()) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
}
cow_ptr& operator=(cow_ptr&& other) {
swap(other);
return *this;
}
cow_ptr& operator=(const cow_ptr& other) {
cow_ptr tmp{other};
swap(tmp);
return *this;
}
inline void swap(cow_ptr& other) { m_ptr.swap(other.m_ptr); }
template<typename Y>
cow_ptr& operator=(const cow_ptr<Y>& other) {
cow_ptr tmp{other};
swap(tmp);
cow_ptr& operator=(cow_ptr<Y> other) {
m_ptr = std::move(other.m_ptr);
return *this;
}
void detach() { (void) detached_ptr();
}
void detach() { static_cast<void>(get_detached()); }
inline void reset(T* value = nullptr) { m_ptr.reset(value); }
inline T* get() { return (m_ptr) ? detached_ptr() : nullptr; }
inline T& operator*() { return *detached_ptr(); }
inline T* operator->() { return detached_ptr(); }
inline const T* get() const { return ptr(); }
inline const T& operator*() const { return *ptr(); }
inline const T* operator->() const { return ptr(); }
// non-const access (detaches this pointer)
inline pointer get() { return (m_ptr) ? get_detached() : nullptr; }
inline pointer operator->() { return get_detached(); }
inline reference operator*() { return *get_detached(); }
// const access (does not detach this pointer)
inline const_pointer get() const { return m_ptr.get(); }
inline const_pointer operator->() const { return get(); }
inline const_reference operator*() const { return *get(); }
inline explicit operator bool() const { return static_cast<bool>(m_ptr); }
template<typename Arg>
inline ptrdiff_t compare(Arg&& what) const {
return m_ptr.compare(std::forward<Arg>(what));
}
private:
intrusive_ptr<T> m_ptr;
T* detached_ptr() {
T* ptr = m_ptr.get();
pointer get_detached() {
auto ptr = m_ptr.get();
if (!ptr->unique()) {
//T* new_ptr = detail::copy_of(ptr, copy_of_token());
T* new_ptr = ptr->copy();
cow_ptr tmp(new_ptr);
swap(tmp);
pointer new_ptr = ptr->copy();
reset(new_ptr);
return new_ptr;
}
return ptr;
}
inline const T* ptr() const { return m_ptr.get(); }
};
/**
* @relates cow_ptr
*/
template<typename X, typename Y>
inline bool operator==(const cow_ptr<X>& lhs, const cow_ptr<Y>& rhs) {
return lhs.get() == rhs.get();
}
/**
* @relates cow_ptr
*/
template<typename X, typename Y>
inline bool operator!=(const cow_ptr<X>& lhs, const cow_ptr<Y>& rhs) {
return !(lhs == rhs);
}
} // namespace cppa
#endif // COW_PTR_HPP
#endif // CPPA_COW_PTR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef CPPA_TUPLE_HPP
#define CPPA_TUPLE_HPP
#ifndef CPPA_COW_TUPLE_HPP
#define CPPA_COW_TUPLE_HPP
#include <cstddef>
#include <string>
......@@ -257,4 +257,4 @@ inline bool operator!=(const cow_tuple<LhsTypes...>& lhs,
} // namespace cppa
#endif
#endif // CPPA_COW_TUPLE_HPP
......@@ -89,18 +89,26 @@
*
* The usual build steps on Linux and Mac OS X are:
*
* - <tt>mkdir build</tt>
* - <tt>cd build</tt>
* - <tt>cmake ..</tt>
* - <tt>make</tt> (as root, optionally)
* - <tt>make install</tt> (as root, optionally)
*- <tt>mkdir build</tt>
*- <tt>cd build</tt>
*- <tt>cmake ..</tt>
*- <tt>make</tt>
*- <tt>make install</tt> (as root, optionally)
*
* Please run the unit tests as well to verify that @p libcppa works properly.
*
*- <tt>./bin/unit_tests</tt>
*
* Please submit a bug report that includes (a) your compiler version,
* (b) your OS, and (c) the output of the unit tests if an error occurs.
*
* Windows is not supported yet, because MVSC++ doesn't implement the
* C++11 features needed to compile @p libcppa.
*
* Please read the <b>Manual</b> for an introduction to @p libcppa.
* It is available online at
* http://neverlord.github.com/libcppa/manual/
* http://neverlord.github.com/libcppa/manual/index.html or as PDF version at
* http://neverlord.github.com/libcppa/manual/libcppa_manual.pdf
*
* @section IntroHelloWorld Hello World Example
*
......
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef DESERIALIZER_HPP
#define DESERIALIZER_HPP
#ifndef CPPA_DESERIALIZER_HPP
#define CPPA_DESERIALIZER_HPP
#include <string>
#include <cstddef>
......@@ -121,4 +121,4 @@ deserializer& operator>>(deserializer& d, object& storage);
} // namespace cppa
#endif // DESERIALIZER_HPP
#endif // CPPA_DESERIALIZER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef SCHEDULED_ACTOR_HPP
#define SCHEDULED_ACTOR_HPP
#ifndef CPPA_SCHEDULED_ACTOR_HPP
#define CPPA_SCHEDULED_ACTOR_HPP
#include <iostream>
......@@ -182,4 +182,4 @@ class abstract_scheduled_actor : public abstract_actor<scheduled_actor> {
} } // namespace cppa::detail
#endif // SCHEDULED_ACTOR_HPP
#endif // CPPA_SCHEDULED_ACTOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ABSTRACT_TUPLE_HPP
#define ABSTRACT_TUPLE_HPP
#ifndef CPPA_ABSTRACT_TUPLE_HPP
#define CPPA_ABSTRACT_TUPLE_HPP
#include <iterator>
#include <typeinfo>
......@@ -128,4 +128,4 @@ constexpr types_only_eq_type types_only_eq;
} } // namespace cppa::detail
#endif // ABSTRACT_TUPLE_HPP
#endif // CPPA_ABSTRACT_TUPLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ACTOR_COUNT_HPP
#define ACTOR_COUNT_HPP
#ifndef CPPA_ACTOR_COUNT_HPP
#define CPPA_ACTOR_COUNT_HPP
#include <cstddef>
......@@ -45,4 +45,4 @@ void actor_count_wait_until(size_t expected);
} } // namespace cppa::detail
#endif // ACTOR_COUNT_HPP
#endif // CPPA_ACTOR_COUNT_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ACTOR_PROXY_CACHE_HPP
#define ACTOR_PROXY_CACHE_HPP
#ifndef CPPA_ACTOR_PROXY_CACHE_HPP
#define CPPA_ACTOR_PROXY_CACHE_HPP
#include <mutex>
#include <thread>
......@@ -99,4 +99,4 @@ actor_proxy_cache& get_actor_proxy_cache();
} } // namespace cppa::detail
#endif // ACTOR_PROXY_CACHE_HPP
#endif // CPPA_ACTOR_PROXY_CACHE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ACTOR_REGISTRY_HPP
#define ACTOR_REGISTRY_HPP
#ifndef CPPA_ACTOR_REGISTRY_HPP
#define CPPA_ACTOR_REGISTRY_HPP
#include <map>
#include <mutex>
......@@ -86,4 +86,4 @@ class actor_registry {
} } // namespace cppa::detail
#endif // ACTOR_REGISTRY_HPP
#endif // CPPA_ACTOR_REGISTRY_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ADDRESSED_MESSAGE_HPP
#define ADDRESSED_MESSAGE_HPP
#ifndef CPPA_ADDRESSED_MESSAGE_HPP
#define CPPA_ADDRESSED_MESSAGE_HPP
#include "cppa/actor.hpp"
#include "cppa/channel.hpp"
......@@ -97,4 +97,4 @@ inline bool operator!=(const addressed_message& lhs, const addressed_message& rh
} } // namespace cppa::detail
#endif // ADDRESSED_MESSAGE_HPP
#endif // CPPA_ADDRESSED_MESSAGE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ATOM_VAL_HPP
#define ATOM_VAL_HPP
#ifndef CPPA_ATOM_VAL_HPP
#define CPPA_ATOM_VAL_HPP
namespace cppa { namespace detail {
......@@ -68,4 +68,4 @@ constexpr std::uint64_t atom_val(const char* cstr, std::uint64_t interim = 0) {
} } // namespace cppa::detail
#endif // ATOM_VAL_HPP
#endif // CPPA_ATOM_VAL_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef BOXED_HPP
#define BOXED_HPP
#ifndef CPPA_BOXED_HPP
#define CPPA_BOXED_HPP
#include "cppa/anything.hpp"
#include "cppa/util/wrapped.hpp"
......@@ -78,4 +78,4 @@ struct is_boxed<util::wrapped<T>(*)()> {
} } // namespace cppa::detail
#endif // BOXED_HPP
#endif // CPPA_BOXED_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef BUFFER_HPP
#define BUFFER_HPP
#ifndef CPPA_BUFFER_HPP
#define CPPA_BUFFER_HPP
#include <ios> // std::ios_base::failure
#include <iostream>
......@@ -173,4 +173,4 @@ class buffer {
} } // namespace cppa::detail
#endif // BUFFER_HPP
#endif // CPPA_BUFFER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef CHANNEL_HPP
#define CHANNEL_HPP
#ifndef CPPA_CHANNEL_HPP
#define CPPA_CHANNEL_HPP
#include "cppa/ref_counted.hpp"
......@@ -39,9 +39,9 @@ namespace cppa { namespace detail {
// public part of the actor interface
struct channel : ref_counted {
virtual void enqueue_msg(const message& msg) = 0;
virtual void enqueue_msg(const message& msg) = 0;
};
} } // namespace cppa::detail
#endif // CHANNEL_HPP
#endif // CPPA_CHANNEL_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef CONTAINER_TUPLE_VIEW_HPP
#define CONTAINER_TUPLE_VIEW_HPP
#ifndef CPPA_CONTAINER_TUPLE_VIEW_HPP
#define CPPA_CONTAINER_TUPLE_VIEW_HPP
#include <iostream>
......@@ -89,4 +89,4 @@ class container_tuple_view : public abstract_tuple {
} } // namespace cppa::detail
#endif // CONTAINER_TUPLE_VIEW_HPP
#endif // CPPA_CONTAINER_TUPLE_VIEW_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef DECORATED_TUPLE_HPP
#define DECORATED_TUPLE_HPP
#ifndef CPPA_DECORATED_TUPLE_HPP
#define CPPA_DECORATED_TUPLE_HPP
#include <vector>
#include <algorithm>
......@@ -144,4 +144,4 @@ struct decorated_cow_tuple_from_type_list< util::type_list<Types...> > {
} } // namespace cppa::detail
#endif // DECORATED_TUPLE_HPP
#endif // CPPA_DECORATED_TUPLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef DEFAULT_UNIFORM_TYPE_INFO_IMPL_HPP
#define DEFAULT_UNIFORM_TYPE_INFO_IMPL_HPP
#ifndef CPPA_DEFAULT_UNIFORM_TYPE_INFO_IMPL_HPP
#define CPPA_DEFAULT_UNIFORM_TYPE_INFO_IMPL_HPP
#include "cppa/anything.hpp"
......@@ -334,4 +334,4 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
} } // namespace detail
#endif // DEFAULT_UNIFORM_TYPE_INFO_IMPL_HPP
#endif // CPPA_DEFAULT_UNIFORM_TYPE_INFO_IMPL_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef DEMANGLE_HPP
#define DEMANGLE_HPP
#ifndef CPPA_DEMANGLE_HPP
#define CPPA_DEMANGLE_HPP
#include <string>
......@@ -39,4 +39,4 @@ std::string demangle(const char* typeid_name);
} } // namespace cppa::detail
#endif // DEMANGLE_HPP
#endif // CPPA_DEMANGLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef DISABLABLE_DELETE_HPP
#define DISABLABLE_DELETE_HPP
#ifndef CPPA_DISABLABLE_DELETE_HPP
#define CPPA_DISABLABLE_DELETE_HPP
namespace cppa { namespace detail {
......@@ -52,4 +52,4 @@ class disablable_delete {
} } // namespace cppa::detail
#endif // DISABLABLE_DELETE_HPP
#endif // CPPA_DISABLABLE_DELETE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef EMPTY_TUPLE_HPP
#define EMPTY_TUPLE_HPP
#ifndef CPPA_EMPTY_TUPLE_HPP
#define CPPA_EMPTY_TUPLE_HPP
#include "cppa/detail/abstract_tuple.hpp"
......@@ -54,4 +54,4 @@ class empty_tuple : public abstract_tuple {
} } // namespace cppa::detail
#endif // EMPTY_TUPLE_HPP
#endif // CPPA_EMPTY_TUPLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef FILTER_RESULT_HPP
#define FILTER_RESULT_HPP
#ifndef CPPA_FILTER_RESULT_HPP
#define CPPA_FILTER_RESULT_HPP
namespace cppa { namespace detail {
......@@ -42,4 +42,4 @@ enum filter_result {
} } // namespace cppa::detail
#endif // FILTER_RESULT_HPP
#endif // CPPA_FILTER_RESULT_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef GET_BEHAVIOR_HPP
#define GET_BEHAVIOR_HPP
#ifndef CPPA_GET_BEHAVIOR_HPP
#define CPPA_GET_BEHAVIOR_HPP
#include <type_traits>
......@@ -167,4 +167,4 @@ scheduled_actor* get_behavior(std::integral_constant<bool,false>,
} } // namespace cppa::detail
#endif // GET_BEHAVIOR_HPP
#endif // CPPA_GET_BEHAVIOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef GROUP_MANAGER_HPP
#define GROUP_MANAGER_HPP
#ifndef CPPA_GROUP_MANAGER_HPP
#define CPPA_GROUP_MANAGER_HPP
#include <map>
#include <mutex>
......@@ -64,4 +64,4 @@ class group_manager {
} } // namespace cppa::detail
#endif // GROUP_MANAGER_HPP
#endif // CPPA_GROUP_MANAGER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef IMPLICIT_CONVERSIONS_HPP
#define IMPLICIT_CONVERSIONS_HPP
#ifndef CPPA_IMPLICIT_CONVERSIONS_HPP
#define CPPA_IMPLICIT_CONVERSIONS_HPP
#include <string>
#include <type_traits>
......@@ -82,4 +82,4 @@ struct strip_and_convert {
} } // namespace cppa::detail
#endif // IMPLICIT_CONVERSIONS_HPP
#endif // CPPA_IMPLICIT_CONVERSIONS_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef INVOKABLE_HPP
#define INVOKABLE_HPP
#include <vector>
#include <memory>
#include <cstddef>
#include <cstdint>
#include "cppa/pattern.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/tuple_cast.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/apply_tuple.hpp"
#include "cppa/util/fixed_vector.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/detail/matches.hpp"
namespace cppa { namespace detail {
class invokable {
invokable(const invokable&) = delete;
invokable& operator=(const invokable&) = delete;
public:
invokable* next;
inline invokable() : next(nullptr) { }
virtual ~invokable();
// Checks whether the types of @p value match the pattern.
virtual bool types_match(const any_tuple& value) const;
// Checks whether this invokable could be invoked with @p value.
virtual bool could_invoke(const any_tuple& value) const;
// Type checking.
virtual bool invoke(any_tuple& value) const;
// Suppress type checking.
virtual bool unsafe_invoke(any_tuple& value) const;
};
enum mapping_policy {
do_not_map,
map_to_bool,
map_to_option
};
template<mapping_policy, class Pattern> // do_not_map
struct pattern_policy {
Pattern m_pattern;
template<typename... Args>
pattern_policy(Args&&... args) : m_pattern(std::forward<Args>(args)...) { }
bool types_match(const any_tuple& value) const {
return matches_types(value, m_pattern);
}
bool could_invoke(const any_tuple& value) const {
return matches(value, m_pattern);
}
template<typename Fun>
bool call(const Fun& fun, any_tuple& value) const {
fun(value);
return true;
}
template<typename Fun>
bool call_unsafe(const Fun& fun, any_tuple& value) const {
fun(value);
return true;
}
};
template<class Pattern>
struct pattern_policy<map_to_option, Pattern> {
Pattern m_pattern;
template<typename... Args>
pattern_policy(Args&&... args) : m_pattern(std::forward<Args>(args)...) { }
bool types_match(const any_tuple& value) const {
return matches_types(value, m_pattern);
}
bool could_invoke(const any_tuple& value) const {
return matches(value, m_pattern);
}
template<typename Fun>
bool call(const Fun& fun, any_tuple& value) const {
auto result = moving_tuple_cast(value, m_pattern);
if (result) {
util::apply_tuple(fun, *result);
return true;
}
return false;
}
template<typename Fun>
bool call_unsafe(const Fun& fun, any_tuple& value) const {
auto result = unsafe_tuple_cast(value, m_pattern);
if (result) {
util::apply_tuple(fun, *result);
return true;
}
return false;
}
};
template<class Pattern>
struct pattern_policy<map_to_bool, Pattern> {
Pattern m_pattern;
template<typename... Args>
pattern_policy(Args&&... args) : m_pattern(std::forward<Args>(args)...) { }
bool types_match(const any_tuple& value) const {
return matches_types(value, m_pattern);
}
bool could_invoke(const any_tuple& value) const {
return matches(value, m_pattern);
}
template<typename Fun>
bool call(const Fun& fun, any_tuple& value) const {
if (could_invoke(value)) {
fun();
return true;
}
return false;
}
template<typename Fun>
bool call_unsafe(const Fun& fun, any_tuple& value) const {
if (could_invoke(value)) {
fun();
return true;
}
return false;
}
};
struct dummy_policy {
inline bool types_match(const any_tuple&) const {
return true;
}
inline bool could_invoke(const any_tuple&) const {
return true;
}
template<typename Fun>
inline bool call(const Fun& fun, any_tuple&) const {
fun();
return true;
}
template<typename Fun>
inline bool call_unsafe(const Fun& fun, any_tuple&) const {
fun();
return true;
}
};
template<typename Fun, class Policy>
struct invokable_impl : public invokable {
Fun m_fun;
Policy m_policy;
template<typename Arg0, typename... Args>
invokable_impl(Arg0&& arg0, Args&&... args)
: m_fun(std::forward<Arg0>(arg0))
, m_policy(std::forward<Args>(args)...) {
}
bool invoke(any_tuple& value) const {
return m_policy.call(m_fun, value);
}
bool unsafe_invoke(any_tuple& value) const {
return m_policy.call_unsafe(m_fun, value);
}
bool types_match(const any_tuple& value) const {
return m_policy.types_match(value);
}
bool could_invoke(const any_tuple& value) const {
return m_policy.could_invoke(value);
}
};
template<class ArgTypes>
constexpr mapping_policy get_mapping_policy() {
return (ArgTypes::size == 0)
? map_to_bool
: (( std::is_same<typename ArgTypes::head, any_tuple>::value
&& ArgTypes::size == 1)
? do_not_map
: map_to_option);
}
template<class Container>
struct filtered;
template<typename... Ts>
struct filtered<util::type_list<Ts...> > {
typedef typename util::tl_filter_not<util::type_list<Ts...>, is_anything>::type
types;
};
template<typename... Ts>
struct filtered<pattern<Ts...> > {
typedef typename filtered<util::type_list<Ts...>>::types types;
};
template<typename Fun, class Pattern>
struct select_invokable_impl {
typedef typename util::get_arg_types<Fun>::types qualified_arg_types;
typedef typename util::tl_map<qualified_arg_types, util::rm_ref>::type
arg_types;
static constexpr mapping_policy mp = get_mapping_policy<arg_types>();
typedef invokable_impl<Fun, pattern_policy<mp, Pattern> > type;
};
template<typename Fun>
struct select_invokable_impl<Fun, pattern<anything> > {
typedef typename util::get_arg_types<Fun>::types qualified_arg_types;
typedef typename util::tl_map<qualified_arg_types, util::rm_ref>::type
arg_types;
typedef typename util::rm_ref<typename arg_types::head>::type arg0;
static_assert(arg_types::size < 2, "functor has too many arguments");
static_assert( arg_types::size == 0
|| std::is_same<any_tuple, arg0>::value,
"bad signature");
typedef invokable_impl<Fun, dummy_policy> type;
};
template<class Pattern, typename Fun>
std::unique_ptr<invokable> get_invokable_impl(Fun&& fun,
std::unique_ptr<value_matcher>&& vm) {
typedef std::unique_ptr<invokable> result;
if (vm) {
typedef typename select_invokable_impl<Fun, Pattern>::type impl1;
return result{new impl1{std::forward<Fun>(fun), std::move(vm)}};
}
typedef typename Pattern::types pattern_types;
typedef typename select_invokable_impl<Fun, pattern_types>::type impl2;
return result{new impl2{std::forward<Fun>(fun)}};
}
template<class Pattern, typename Fun>
std::unique_ptr<invokable> get_invokable_impl(Fun&& fun) {
typedef typename Pattern::types pattern_types;
typedef typename select_invokable_impl<Fun, pattern_types>::type impl;
return std::unique_ptr<invokable>{new impl(std::forward<Fun>(fun))};
}
} } // namespace cppa::detail
#endif // INVOKABLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef LIST_MEMBER_HPP
#define LIST_MEMBER_HPP
#ifndef CPPA_LIST_MEMBER_HPP
#define CPPA_LIST_MEMBER_HPP
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/abstract_uniform_type_info.hpp"
......@@ -108,4 +108,4 @@ class list_member : public util::abstract_uniform_type_info<List> {
} } // namespace cppa::detail
#endif // LIST_MEMBER_HPP
#endif // CPPA_LIST_MEMBER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef MAILMAN_HPP
#define MAILMAN_HPP
#ifndef CPPA_MAILMAN_HPP
#define CPPA_MAILMAN_HPP
#include "cppa/any_tuple.hpp"
#include "cppa/actor_proxy.hpp"
......@@ -44,4 +44,4 @@ void mailman_loop();
}} // namespace cppa::detail
#endif // MAILMAN_HPP
#endif // CPPA_MAILMAN_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef MAP_MEMBER_HPP
#define MAP_MEMBER_HPP
#ifndef CPPA_MAP_MEMBER_HPP
#define CPPA_MAP_MEMBER_HPP
#include <type_traits>
#include "cppa/detail/pair_member.hpp"
......@@ -147,4 +147,4 @@ class map_member : public util::abstract_uniform_type_info<Map> {
} } // namespace cppa::detail
#endif // MAP_MEMBER_HPP
#endif // CPPA_MAP_MEMBER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef MATCHES_HPP
#define MATCHES_HPP
#ifndef CPPA_MATCHES_HPP
#define CPPA_MATCHES_HPP
#include <numeric>
#include "cppa/pattern.hpp"
......@@ -432,4 +432,4 @@ inline bool matches_types(const any_tuple& tup, const util::type_list<Ts...>&) {
} } // namespace cppa::detail
#endif // MATCHES_HPP
#endif // CPPA_MATCHES_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef MOCK_SCHEDULER_HPP
#define MOCK_SCHEDULER_HPP
#ifndef CPPA_MOCK_SCHEDULER_HPP
#define CPPA_MOCK_SCHEDULER_HPP
#include <thread>
#include <utility>
......@@ -57,4 +57,4 @@ class mock_scheduler : public scheduler {
} } // namespace cppa::detail
#endif // MOCK_SCHEDULER_HPP
#endif // CPPA_MOCK_SCHEDULER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef NATIVE_SOCKET_HPP
#define NATIVE_SOCKET_HPP
#ifndef CPPA_NATIVE_SOCKET_HPP
#define CPPA_NATIVE_SOCKET_HPP
#include "cppa/config.hpp"
......@@ -59,4 +59,4 @@ namespace cppa { namespace detail {
} } // namespace cppa::detail
#endif // NATIVE_SOCKET_HPP
#endif // CPPA_NATIVE_SOCKET_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef NESTABLE_RECEIVE_POLICY_HPP
#define NESTABLE_RECEIVE_POLICY_HPP
#ifndef CPPA_NESTABLE_RECEIVE_POLICY_HPP
#define CPPA_NESTABLE_RECEIVE_POLICY_HPP
#include <list>
#include <memory>
......@@ -169,4 +169,4 @@ class nestable_receive_policy {
} } // namespace cppa::detail
#endif // NESTABLE_RECEIVE_POLICY_HPP
#endif // CPPA_NESTABLE_RECEIVE_POLICY_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef NETWORK_MANAGER_HPP
#define NETWORK_MANAGER_HPP
#ifndef CPPA_NETWORK_MANAGER_HPP
#define CPPA_NETWORK_MANAGER_HPP
#include "cppa/detail/post_office.hpp"
......@@ -57,4 +57,4 @@ class network_manager {
} } // namespace cppa::detail
#endif // NETWORK_MANAGER_HPP
#endif // CPPA_NETWORK_MANAGER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef OBJECT_ARRAY_HPP
#define OBJECT_ARRAY_HPP
#ifndef CPPA_OBJECT_ARRAY_HPP
#define CPPA_OBJECT_ARRAY_HPP
#include <vector>
......@@ -74,4 +74,4 @@ class object_array : public abstract_tuple {
} } // namespace cppa::detail
#endif // OBJECT_ARRAY_HPP
#endif // CPPA_OBJECT_ARRAY_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef OBJECT_IMPL_HPP
#define OBJECT_IMPL_HPP
#ifndef CPPA_OBJECT_IMPL_HPP
#define CPPA_OBJECT_IMPL_HPP
#include "cppa/object.hpp"
......@@ -44,21 +44,21 @@ namespace cppa { namespace detail {
template<typename T>
struct obj_impl : object {
T m_value;
obj_impl() : m_value() { }
obj_impl(const T& v) : m_value(v) { }
virtual object* copy() const { return new obj_impl(m_value); }
virtual const utype& type() const { return uniform_type_info<T>(); }
virtual void* mutable_value() { return &m_value; }
virtual const void* value() const { return &m_value; }
virtual void serialize(serializer& s) const {
s << m_value;
}
virtual void deserialize(deserializer& d) {
d >> m_value;
}
T m_value;
obj_impl() : m_value() { }
obj_impl(const T& v) : m_value(v) { }
virtual object* copy() const { return new obj_impl(m_value); }
virtual const utype& type() const { return uniform_type_info<T>(); }
virtual void* mutable_value() { return &m_value; }
virtual const void* value() const { return &m_value; }
virtual void serialize(serializer& s) const {
s << m_value;
}
virtual void deserialize(deserializer& d) {
d >> m_value;
}
};
} } // namespace cppa::detail
#endif // OBJECT_IMPL_HPP
#endif // CPPA_OBJECT_IMPL_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef PAIR_MEMBER_HPP
#define PAIR_MEMBER_HPP
#ifndef CPPA_PAIR_MEMBER_HPP
#define CPPA_PAIR_MEMBER_HPP
#include <utility>
......@@ -73,4 +73,4 @@ class pair_member : public util::abstract_uniform_type_info<std::pair<T1,T2>> {
} } // namespace cppa::detail
#endif // PAIR_MEMBER_HPP
#endif // CPPA_PAIR_MEMBER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef POST_OFFICE_HPP
#define POST_OFFICE_HPP
#ifndef CPPA_POST_OFFICE_HPP
#define CPPA_POST_OFFICE_HPP
#include <memory>
......@@ -59,4 +59,4 @@ void post_office_close_socket(native_socket_type sfd);
} } // namespace cppa::detail
#endif // POST_OFFICE_HPP
#endif // CPPA_POST_OFFICE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef PRIMITIVE_MEMBER_HPP
#define PRIMITIVE_MEMBER_HPP
#ifndef CPPA_PRIMITIVE_MEMBER_HPP
#define CPPA_PRIMITIVE_MEMBER_HPP
#include "cppa/serializer.hpp"
#include "cppa/deserializer.hpp"
......@@ -63,4 +63,4 @@ class primitive_member : public util::abstract_uniform_type_info<T> {
} } // namespace cppa::detail
#endif // PRIMITIVE_MEMBER_HPP
#endif // CPPA_PRIMITIVE_MEMBER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef PROJECTION_HPP
#define PROJECTION_HPP
#ifndef CPPA_PROJECTION_HPP
#define CPPA_PROJECTION_HPP
#include "cppa/option.hpp"
#include "cppa/guard_expr.hpp"
......@@ -175,4 +175,4 @@ struct projection_from_type_list<ProjectionFuns, util::type_list<Args...> > {
} } // namespace cppa::detail
#endif // PROJECTION_HPP
#endif // CPPA_PROJECTION_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef PSEUDO_TUPLE_HPP
#define PSEUDO_TUPLE_HPP
#ifndef CPPA_PSEUDO_TUPLE_HPP
#define CPPA_PSEUDO_TUPLE_HPP
#include "cppa/util/at.hpp"
......@@ -81,4 +81,4 @@ typename util::at<N, Tn...>::type& get_ref(detail::pseudo_tuple<Tn...>& tv) {
} // namespace cppa
#endif // PSEUDO_TUPLE_HPP
#endif // CPPA_PSEUDO_TUPLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef PTYPE_TO_TYPE_HPP
#define PTYPE_TO_TYPE_HPP
#ifndef CPPA_PTYPE_TO_TYPE_HPP
#define CPPA_PTYPE_TO_TYPE_HPP
#include <cstdint>
......@@ -67,4 +67,4 @@ struct ptype_to_type :
} } // namespace cppa::detail
#endif // PTYPE_TO_TYPE_HPP
#endif // CPPA_PTYPE_TO_TYPE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef RECEIVE_LOOP_HELPER_HPP
#define RECEIVE_LOOP_HELPER_HPP
#ifndef CPPA_RECEIVE_LOOP_HELPER_HPP
#define CPPA_RECEIVE_LOOP_HELPER_HPP
#include <new>
......@@ -41,9 +41,6 @@
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/detail/invokable.hpp"
namespace cppa { namespace detail {
template<typename Statement>
......@@ -136,4 +133,4 @@ class do_receive_helper {
} } // namespace cppa::detail
#endif // RECEIVE_LOOP_HELPER_HPP
#endif // CPPA_RECEIVE_LOOP_HELPER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef RECURSIVE_QUEUE_NODE_HPP
#define RECURSIVE_QUEUE_NODE_HPP
#ifndef CPPA_RECURSIVE_QUEUE_NODE_HPP
#define CPPA_RECURSIVE_QUEUE_NODE_HPP
#include "cppa/actor.hpp"
#include "cppa/any_tuple.hpp"
......@@ -61,4 +61,4 @@ struct recursive_queue_node {
} } // namespace cppa::detail
#endif // RECURSIVE_QUEUE_NODE_HPP
#endif // CPPA_RECURSIVE_QUEUE_NODE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef REF_COUNTED_IMPL_HPP
#define REF_COUNTED_IMPL_HPP
#ifndef CPPA_REF_COUNTED_IMPL_HPP
#define CPPA_REF_COUNTED_IMPL_HPP
namespace cppa { namespace detail {
......@@ -58,4 +58,4 @@ class ref_counted_impl {
} } // namespace cppa::detail
#endif // REF_COUNTED_IMPL_HPP
#endif // CPPA_REF_COUNTED_IMPL_HPP
......@@ -28,15 +28,15 @@
\******************************************************************************/
#ifndef SCHEDULED_ACTOR_DUMMY_HPP
#define SCHEDULED_ACTOR_DUMMY_HPP
#ifndef CPPA_SCHEDULED_ACTOR_DUMMY_HPP
#define CPPA_SCHEDULED_ACTOR_DUMMY_HPP
#include "cppa/detail/abstract_scheduled_actor.hpp"
namespace cppa { namespace detail {
struct scheduled_actor_dummy : abstract_scheduled_actor {
void resume(util::fiber*, scheduler::callback*);
resume_result resume(util::fiber*);
void quit(std::uint32_t);
void dequeue(behavior&);
void dequeue(partial_function&);
......@@ -50,4 +50,4 @@ struct scheduled_actor_dummy : abstract_scheduled_actor {
} } // namespace cppa::detail
#endif // SCHEDULED_ACTOR_DUMMY_HPP
#endif // CPPA_SCHEDULED_ACTOR_DUMMY_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef SERIALIZE_TUPLE_HPP
#define SERIALIZE_TUPLE_HPP
#ifndef CPPA_SERIALIZE_TUPLE_HPP
#define CPPA_SERIALIZE_TUPLE_HPP
#include <cstddef>
......@@ -58,4 +58,4 @@ struct serialize_tuple<util::type_list<>, Pos> {
} } // namespace cppa::detail
#endif // SERIALIZE_TUPLE_HPP
#endif // CPPA_SERIALIZE_TUPLE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef SINGLETON_MANAGER_HPP
#define SINGLETON_MANAGER_HPP
#ifndef CPPA_SINGLETON_MANAGER_HPP
#define CPPA_SINGLETON_MANAGER_HPP
namespace cppa {
......@@ -74,4 +74,4 @@ class singleton_manager {
} } // namespace cppa::detail
#endif // SINGLETON_MANAGER_HPP
#endif // CPPA_SINGLETON_MANAGER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef SWAP_BYTES_HPP
#define SWAP_BYTES_HPP
#ifndef CPPA_SWAP_BYTES_HPP
#define CPPA_SWAP_BYTES_HPP
#include <cstddef>
......@@ -68,4 +68,4 @@ inline T swap_bytes(T what) {
} } // namespace cppa::detail
#endif // SWAP_BYTES_HPP
#endif // CPPA_SWAP_BYTES_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TDATA_HPP
#define TDATA_HPP
#ifndef CPPA_TDATA_HPP
#define CPPA_TDATA_HPP
#include <typeinfo>
#include <functional>
......@@ -439,4 +439,4 @@ typename util::at<N, Tn...>::type& get_ref(detail::tdata<Tn...>& tv) {
} // namespace cppa
#endif // TDATA_HPP
#endif // CPPA_TDATA_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef THREAD_POOL_SCHEDULER_HPP
#define THREAD_POOL_SCHEDULER_HPP
#ifndef CPPA_THREAD_POOL_SCHEDULER_HPP
#define CPPA_THREAD_POOL_SCHEDULER_HPP
#include <thread>
......@@ -77,4 +77,4 @@ class thread_pool_scheduler : public scheduler {
} } // namespace cppa::detail
#endif // THREAD_POOL_SCHEDULER_HPP
#endif // CPPA_THREAD_POOL_SCHEDULER_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TO_UNIFORM_NAME_HPP
#define TO_UNIFORM_NAME_HPP
#ifndef CPPA_TO_UNIFORM_NAME_HPP
#define CPPA_TO_UNIFORM_NAME_HPP
#include <string>
#include <typeinfo>
......@@ -41,4 +41,4 @@ std::string to_uniform_name(const std::type_info& tinfo);
} } // namespace cppa::detail
#endif // TO_UNIFORM_NAME_HPP
#endif // CPPA_TO_UNIFORM_NAME_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TUPLE_CAST_IMPL_HPP
#define TUPLE_CAST_IMPL_HPP
#ifndef CPPA_TUPLE_CAST_IMPL_HPP
#define CPPA_TUPLE_CAST_IMPL_HPP
#include "cppa/pattern.hpp"
#include "cppa/any_tuple.hpp"
......@@ -179,4 +179,4 @@ struct tuple_cast_impl<wildcard_position::leading, Result, T...> {
} }
#endif // TUPLE_CAST_IMPL_HPP
#endif // CPPA_TUPLE_CAST_IMPL_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TUPLE_ITERATOR_HPP
#define TUPLE_ITERATOR_HPP
#ifndef CPPA_TUPLE_ITERATOR_HPP
#define CPPA_TUPLE_ITERATOR_HPP
#include <cstddef>
......@@ -109,4 +109,4 @@ class tuple_iterator {
} } // namespace cppa::detail
#endif // TUPLE_ITERATOR_HPP
#endif // CPPA_TUPLE_ITERATOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TUPLE_VALS_HPP
#define TUPLE_VALS_HPP
#ifndef CPPA_TUPLE_VALS_HPP
#define CPPA_TUPLE_VALS_HPP
#include <stdexcept>
......@@ -137,4 +137,4 @@ struct tuple_vals_from_type_list< util::type_list<Types...> > {
} } // namespace cppa::detail
#endif // TUPLE_VALS_HPP
#endif // CPPA_TUPLE_VALS_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TUPLE_VIEW_HPP
#define TUPLE_VIEW_HPP
#ifndef CPPA_TUPLE_VIEW_HPP
#define CPPA_TUPLE_VIEW_HPP
#include "cppa/util/static_foreach.hpp"
......@@ -123,4 +123,4 @@ types_array<ElementTypes...> tuple_view<ElementTypes...>::m_types;
} } // namespace cppa::detail
#endif // TUPLE_VIEW_HPP
#endif // CPPA_TUPLE_VIEW_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef TYPE_TO_PTYPE_HPP
#define TYPE_TO_PTYPE_HPP
#ifndef CPPA_TYPE_TO_PTYPE_HPP
#define CPPA_TYPE_TO_PTYPE_HPP
#include <string>
#include <cstdint>
......@@ -93,4 +93,4 @@ struct type_to_ptype {
} } // namespace cppa::detail
#endif // TYPE_TO_PTYPE_HPP
#endif // CPPA_TYPE_TO_PTYPE_HPP
#ifndef TYPES_ARRAY_HPP
#define TYPES_ARRAY_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_TYPES_ARRAY_HPP
#define CPPA_TYPES_ARRAY_HPP
#include <typeinfo>
......@@ -163,4 +193,4 @@ const std::type_info* static_type_list<T...>::list = &typeid(util::type_list<T..
} } // namespace cppa::detail
#endif // TYPES_ARRAY_HPP
#endif // CPPA_TYPES_ARRAY_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef UNBOXED_HPP
#define UNBOXED_HPP
#ifndef CPPA_UNBOXED_HPP
#define CPPA_UNBOXED_HPP
#include <memory>
......@@ -70,4 +70,4 @@ struct unboxed<std::unique_ptr<util::guard<T>>> {
} } // namespace cppa::detail
#endif // UNBOXED_HPP
#endif // CPPA_UNBOXED_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef UNIFORM_TYPE_INFO_MAP_HPP
#define UNIFORM_TYPE_INFO_MAP_HPP
#ifndef CPPA_UNIFORM_TYPE_INFO_MAP_HPP
#define CPPA_UNIFORM_TYPE_INFO_MAP_HPP
#include <set>
#include <string>
......@@ -90,4 +90,4 @@ class uniform_type_info_map {
} } // namespace cppa::detail
#endif // UNIFORM_TYPE_INFO_MAP_HPP
#endif // CPPA_UNIFORM_TYPE_INFO_MAP_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef VALUE_GUARD_HPP
#define VALUE_GUARD_HPP
#ifndef CPPA_VALUE_GUARD_HPP
#define CPPA_VALUE_GUARD_HPP
#include <type_traits>
......@@ -131,4 +131,4 @@ class value_guard {
} } // namespace cppa::detail
#endif // VALUE_GUARD_HPP
#endif // CPPA_VALUE_GUARD_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef YIELD_INTERFACE_HPP
#define YIELD_INTERFACE_HPP
#ifndef CPPA_YIELD_INTERFACE_HPP
#define CPPA_YIELD_INTERFACE_HPP
#include "cppa/util/fiber.hpp"
......@@ -54,4 +54,4 @@ yield_state call(util::fiber* what, util::fiber* from);
} } // namespace cppa::detail
#endif // YIELD_INTERFACE_HPP
#endif // CPPA_YIELD_INTERFACE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef EITHER_HPP
#define EITHER_HPP
#ifndef CPPA_EITHER_HPP
#define CPPA_EITHER_HPP
#include <new>
#include <utility>
......@@ -252,4 +252,4 @@ bool operator!=(const Right& lhs, const either<Left, Right>& rhs) {
} // namespace cppa
#endif // EITHER_HPP
#endif // CPPA_EITHER_HPP
......@@ -28,17 +28,42 @@
\******************************************************************************/
#ifndef EVENT_BASED_ACTOR_HPP
#define EVENT_BASED_ACTOR_HPP
#ifndef CPPA_EVENT_BASED_ACTOR_HPP
#define CPPA_EVENT_BASED_ACTOR_HPP
#include "cppa/behavior.hpp"
#include "cppa/event_based_actor_base.hpp"
namespace cppa {
#ifdef CPPA_DOCUMENTATION
/**
* @brief Base class for non-stacked event-based actor implementations.
*/
class event_based_actor : public scheduled_actor {
protected:
/**
* @brief Sets the actor's behavior to @p bhvr.
* @note @p bhvr is owned by the caller and must remain valid until
* the actor terminates.
* @note The recommended way of using this member function is to pass
* a pointer to a member variable.
*/
void become(behavior* bhvr);
/**
* @brief Sets the actor's behavior.
*/
template<typename Arg0, typename... Args>
void become(Arg0&& arg0, Args&&... args):
};
#else
class event_based_actor : public event_based_actor_base<event_based_actor> {
friend class event_based_actor_base<event_based_actor>;
......@@ -52,10 +77,12 @@ class event_based_actor : public event_based_actor_base<event_based_actor> {
event_based_actor();
void quit(std::uint32_t reason);
virtual void quit(std::uint32_t reason = exit_reason::normal);
};
#endif
} // namespace cppa
#endif // EVENT_BASED_ACTOR_HPP
#endif // CPPA_EVENT_BASED_ACTOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef EVENT_BASED_ACTOR_MIXIN_HPP
#define EVENT_BASED_ACTOR_MIXIN_HPP
#ifndef CPPA_EVENT_BASED_ACTOR_BASE_HPP
#define CPPA_EVENT_BASED_ACTOR_BASE_HPP
#include "cppa/behavior.hpp"
#include "cppa/abstract_event_based_actor.hpp"
......@@ -71,4 +71,4 @@ class event_based_actor_base : public abstract_event_based_actor {
} // namespace cppa
#endif // EVENT_BASED_ACTOR_MIXIN_HPP
#endif // CPPA_EVENT_BASED_ACTOR_BASE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef EXCEPTION_HPP
#define EXCEPTION_HPP
#ifndef CPPA_EXCEPTION_HPP
#define CPPA_EXCEPTION_HPP
#include <string>
#include <cstdint>
......@@ -140,4 +140,4 @@ inline int bind_failure::error_code() const throw() {
} // namespace cppa
#endif // EXCEPTION_HPP
#endif // CPPA_EXCEPTION_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef EXIT_REASON_HPP
#define EXIT_REASON_HPP
#ifndef CPPA_EXIT_REASON_HPP
#define CPPA_EXIT_REASON_HPP
#include <cstdint>
......@@ -78,4 +78,4 @@ static constexpr std::uint32_t user_defined = 0x10000;
} } // namespace cppa::exit_reason
#endif // EXIT_REASON_HPP
#endif // CPPA_EXIT_REASON_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef FROM_STRING_HPP
#define FROM_STRING_HPP
#ifndef CPPA_FROM_STRING_HPP
#define CPPA_FROM_STRING_HPP
#include <string>
#include <typeinfo>
......@@ -73,4 +73,4 @@ T from_string(const std::string& what) {
} // namespace cppa
#endif // FROM_STRING_HPP
#endif // CPPA_FROM_STRING_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef FSM_ACTOR_HPP
#define FSM_ACTOR_HPP
#ifndef CPPA_FSM_ACTOR_HPP
#define CPPA_FSM_ACTOR_HPP
#include <type_traits>
......@@ -61,4 +61,4 @@ class fsm_actor : public event_based_actor {
} // namespace cppa
#endif // FSM_ACTOR_HPP
#endif // CPPA_FSM_ACTOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef GET_HPP
#define GET_HPP
#ifndef CPPA_GET_HPP
#define CPPA_GET_HPP
// functions are documented in the implementation headers
#ifndef CPPA_DOCUMENTATION
......@@ -83,4 +83,4 @@ typename util::at<N, Ts...>::type get(const util::type_list<Ts...>&) {
} // namespace cppa
#endif // CPPA_DOCUMENTATION
#endif // GET_HPP
#endif // CPPA_GET_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef GROUP_HPP
#define GROUP_HPP
#ifndef CPPA_GROUP_HPP
#define CPPA_GROUP_HPP
#include <string>
#include <memory>
......@@ -172,4 +172,4 @@ typedef intrusive_ptr<group> group_ptr;
} // namespace cppa
#endif // GROUP_HPP
#endif // CPPA_GROUP_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef GUARD_EXPR_HPP
#define GUARD_EXPR_HPP
#ifndef CPPA_GUARD_EXPR_HPP
#define CPPA_GUARD_EXPR_HPP
#include <string>
#include <vector>
......@@ -742,4 +742,4 @@ constexpr guard_placeholder<8> _x9;
} // namespace cppa
#endif // GUARD_EXPR_HPP
#endif // CPPA_GUARD_EXPR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ITERATOR_HPP
#define ITERATOR_HPP
#ifndef CPPA_FORWARD_ITERATOR_HPP
#define CPPA_FORWARD_ITERATOR_HPP
#include <iterator>
......@@ -122,7 +122,7 @@ inline bool operator==(const T* lhs, const forward_iterator<T>& rhs) {
* @relates forward_iterator
*/
template<class T>
inline bool operator==(const forward_iterator<T>& lhs, decltype(nullptr)) {
inline bool operator==(const forward_iterator<T>& lhs, std::nullptr_t) {
return lhs.ptr() == nullptr;
}
......@@ -130,7 +130,7 @@ inline bool operator==(const forward_iterator<T>& lhs, decltype(nullptr)) {
* @relates forward_iterator
*/
template<class T>
inline bool operator==(decltype(nullptr), const forward_iterator<T>& rhs) {
inline bool operator==(std::nullptr_t, const forward_iterator<T>& rhs) {
return rhs.ptr() == nullptr;
}
......@@ -163,7 +163,7 @@ inline bool operator!=(const T* lhs, const forward_iterator<T>& rhs) {
* @relates forward_iterator
*/
template<class T>
inline bool operator!=(const forward_iterator<T>& lhs, decltype(nullptr)) {
inline bool operator!=(const forward_iterator<T>& lhs, std::nullptr_t) {
return !(lhs == nullptr);
}
......@@ -171,11 +171,11 @@ inline bool operator!=(const forward_iterator<T>& lhs, decltype(nullptr)) {
* @relates forward_iterator
*/
template<class T>
inline bool operator!=(decltype(nullptr), const forward_iterator<T>& rhs) {
inline bool operator!=(std::nullptr_t, const forward_iterator<T>& rhs) {
return !(nullptr == rhs);
}
} } // namespace cppa::intrusive
#endif // ITERATOR_HPP
#endif // CPPA_FORWARD_ITERATOR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef SINGLE_READER_QUEUE_HPP
#define SINGLE_READER_QUEUE_HPP
#ifndef CPPA_SINGLE_READER_QUEUE_HPP
#define CPPA_SINGLE_READER_QUEUE_HPP
#include <list>
#include <mutex>
......@@ -200,4 +200,4 @@ class single_reader_queue {
} } // namespace cppa::util
#endif // SINGLE_READER_QUEUE_HPP
#endif // CPPA_SINGLE_READER_QUEUE_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef SINGLY_LINKED_LIST_HPP
#define SINGLY_LINKED_LIST_HPP
#ifndef CPPA_SINGLY_LINKED_LIST_HPP
#define CPPA_SINGLY_LINKED_LIST_HPP
#include <cstddef>
#include <utility>
......@@ -354,4 +354,4 @@ class singly_linked_list {
} } // namespace cppa::intrusive
#endif // SINGLY_LINKED_LIST_HPP
#endif // CPPA_SINGLY_LINKED_LIST_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef INTRUSIVE_PTR_HPP
#define INTRUSIVE_PTR_HPP
#ifndef CPPA_INTRUSIVE_PTR_HPP
#define CPPA_INTRUSIVE_PTR_HPP
#include <cstddef>
#include <algorithm>
......@@ -52,85 +52,76 @@ struct convertible {
* @relates ref_counted
*/
template<typename T>
class intrusive_ptr : util::comparable<intrusive_ptr<T>, const T*>,
util::comparable<intrusive_ptr<T> > {
class intrusive_ptr : util::comparable<intrusive_ptr<T> >,
util::comparable<intrusive_ptr<T>, const T*>,
util::comparable<intrusive_ptr<T>, std::nullptr_t> {
public:
constexpr intrusive_ptr() : m_ptr(nullptr) { }
typedef T* pointer;
typedef const T* const_pointer;
typedef T element_type;
typedef T& reference;
typedef const T& const_reference;
intrusive_ptr(T* raw_ptr) { set_ptr(raw_ptr); }
constexpr intrusive_ptr() : m_ptr(nullptr) { }
intrusive_ptr(const intrusive_ptr& other) { set_ptr(other.m_ptr); }
intrusive_ptr(pointer raw_ptr) { set_ptr(raw_ptr); }
intrusive_ptr(intrusive_ptr&& other) : m_ptr(other.release()) { }
// enables "actor_ptr s = self"
template<typename From>
intrusive_ptr(const convertible<From, T*>& from) {
set_ptr(from.convert());
}
intrusive_ptr(const intrusive_ptr& other) { set_ptr(other.get()); }
template<typename Y>
intrusive_ptr(const intrusive_ptr<Y>& other) {
intrusive_ptr(intrusive_ptr<Y> other) : m_ptr(other.release()) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
set_ptr(const_cast<Y*>(other.get()));
}
template<typename Y>
intrusive_ptr(intrusive_ptr<Y>&& other) : m_ptr(other.release()) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
// enables "actor_ptr s = self"
template<typename From>
intrusive_ptr(const convertible<From, pointer>& from) {
set_ptr(from.convert());
}
~intrusive_ptr() {
if (m_ptr && !m_ptr->deref()) {
delete m_ptr;
}
if (m_ptr && !m_ptr->deref()) delete m_ptr;
}
inline T* get() { return m_ptr; }
inline const T* get() const { return m_ptr; }
inline void swap(intrusive_ptr& other) {
std::swap(m_ptr, other.m_ptr);
}
T* release() {
pointer release() {
auto result = m_ptr;
m_ptr = nullptr;
return result;
}
inline void swap(intrusive_ptr& other) {
std::swap(m_ptr, other.m_ptr);
}
void reset(T* new_value = nullptr) {
void reset(pointer new_value = nullptr) {
if (m_ptr && !m_ptr->deref()) delete m_ptr;
set_ptr(new_value);
}
intrusive_ptr& operator=(T* ptr) {
intrusive_ptr& operator=(pointer ptr) {
reset(ptr);
return *this;
}
intrusive_ptr& operator=(const intrusive_ptr& other) {
intrusive_ptr tmp(other);
swap(tmp);
intrusive_ptr& operator=(intrusive_ptr&& other) {
swap(other);
return *this;
}
intrusive_ptr& operator=(intrusive_ptr&& other) {
reset();
swap(other);
intrusive_ptr& operator=(const intrusive_ptr& other) {
intrusive_ptr tmp{other};
swap(tmp);
return *this;
}
template<typename Y>
intrusive_ptr& operator=(const intrusive_ptr<Y>& other) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
intrusive_ptr tmp(other);
intrusive_ptr& operator=(intrusive_ptr<Y> other) {
intrusive_ptr tmp{std::move(other)};
swap(tmp);
return *this;
}
......@@ -141,26 +132,13 @@ class intrusive_ptr : util::comparable<intrusive_ptr<T>, const T*>,
return *this;
}
template<typename Y>
intrusive_ptr& operator=(intrusive_ptr<Y>&& other) {
static_assert(std::is_convertible<Y*, T*>::value,
"Y* is not assignable to T*");
reset();
m_ptr = other.release();
return *this;
}
inline T& operator*() { return *m_ptr; }
inline T* operator->() { return m_ptr; }
inline const T& operator*() const { return *m_ptr; }
inline const T* operator->() const { return m_ptr; }
inline pointer get() const { return m_ptr; }
inline pointer operator->() const { return m_ptr; }
inline reference operator*() const { return *m_ptr; }
inline explicit operator bool() const { return m_ptr != nullptr; }
inline ptrdiff_t compare(const T* ptr) const {
inline ptrdiff_t compare(const_pointer ptr) const {
return static_cast<ptrdiff_t>(get() - ptr);
}
......@@ -168,59 +146,31 @@ class intrusive_ptr : util::comparable<intrusive_ptr<T>, const T*>,
return compare(other.get());
}
inline ptrdiff_t compare(std::nullptr_t) const {
return reinterpret_cast<ptrdiff_t>(get());
}
template<class C>
intrusive_ptr<C> downcast() const {
return (m_ptr) ? dynamic_cast<C*>(const_cast<T*>(m_ptr)) : nullptr;
return (m_ptr) ? dynamic_cast<C*>(get()) : nullptr;
}
template<class C>
intrusive_ptr<C> upcast() const {
return (m_ptr) ? static_cast<C*>(const_cast<T*>(m_ptr)) : nullptr;
return (m_ptr) ? static_cast<C*>(get()) : nullptr;
}
private:
T* m_ptr;
pointer m_ptr;
inline void set_ptr(T* raw_ptr) {
inline void set_ptr(pointer raw_ptr) {
m_ptr = raw_ptr;
if (raw_ptr) raw_ptr->ref();
}
};
/**
* @relates intrusive_ptr
*/
template<typename X>
inline bool operator==(const intrusive_ptr<X>& ptr, decltype(nullptr)) {
return ptr.get() == nullptr;
}
/**
* @relates intrusive_ptr
*/
template<typename X>
inline bool operator==(decltype(nullptr), const intrusive_ptr<X>& ptr) {
return ptr.get() == nullptr;
}
/**
* @relates intrusive_ptr
*/
template<typename X>
inline bool operator!=(const intrusive_ptr<X>& lhs, decltype(nullptr)) {
return lhs.get() != nullptr;
}
/**
* @relates intrusive_ptr
*/
template<typename X>
inline bool operator!=(decltype(nullptr), const intrusive_ptr<X>& rhs) {
return rhs.get() != nullptr;
}
/**
* @relates intrusive_ptr
*/
......@@ -239,4 +189,4 @@ inline bool operator!=(const intrusive_ptr<X>& lhs, const intrusive_ptr<Y>& rhs)
} // namespace cppa
#endif // INTRUSIVE_PTR_HPP
#endif // CPPA_INTRUSIVE_PTR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef CONTEXT_HPP
#define CONTEXT_HPP
#ifndef CPPA_CONTEXT_HPP
#define CPPA_CONTEXT_HPP
#include "cppa/actor.hpp"
#include "cppa/behavior.hpp"
......@@ -49,78 +49,112 @@ class local_actor : public actor {
friend class scheduler;
protected:
bool m_chaining;
bool m_trap_exit;
bool m_is_scheduled;
actor_ptr m_chained;
actor_ptr m_last_sender;
any_tuple m_last_dequeued;
public:
local_actor(bool is_scheduled = false);
/**
* @brief Finishes execution of this actor.
*
* Causes this actor to send an exit signal to all of its
* linked actors, sets its state to @c exited and throws
* {@link actor_exited} to cleanup the stack.
* @param reason Exit reason that will be send to linked actors.
* @throws actor_exited
* Causes this actor to send an exit message to all of its
* linked actors, sets its state to @c exited and finishes execution.
* @param reason Exit reason that will be send to
* linked actors and monitors.
*/
virtual void quit(std::uint32_t reason) = 0;
inline void quit_normal() {
quit(exit_reason::normal);
}
virtual void quit(std::uint32_t reason = exit_reason::normal) = 0;
/**
* @brief
* @param rules
* @warning Call only from the owner of the queue.
* @brief Removes the first element from the mailbox @p pfun is defined
* for and invokes @p pfun with the removed element.
* Blocks until a matching message arrives if @p pfun is not
* defined for any message in the actor's mailbox.
* @param pfun A partial function denoting the actor's response to the
* next incoming message.
* @warning You should not call this member function by hand.
* Use the {@link cppa::receive receive} function or
* the @p become member function in case of event-based actors.
*/
virtual void dequeue(behavior& rules) = 0;
virtual void dequeue(partial_function& pfun) = 0;
/**
* @brief Removes the first element from the queue that is matched
* by @p rules and invokes the corresponding callback.
* @param rules
* @warning Call only from the owner of the queue.
* @brief Removes the first element from the mailbox @p bhvr is defined
* for and invokes @p bhvr with the removed element.
* Blocks until either a matching message arrives if @p bhvr is not
* defined for any message in the actor's mailbox or until a
* timeout occurs.
* @param bhvr A partial function with optional timeout denoting the
* actor's response to the next incoming message.
* @warning You should not call this member function by hand.
* Use the {@link cppa::receive receive} function or
* the @p become member function in case of event-based actors.
*/
virtual void dequeue(partial_function& rules) = 0;
virtual void dequeue(behavior& bhvr) = 0;
/**
* @brief Checks whether this actor traps exit messages.
*/
inline bool trap_exit() const {
return m_trap_exit;
}
/**
* @brief Enables or disables trapping of exit messages.
*/
inline void trap_exit(bool new_value) {
m_trap_exit = new_value;
}
/**
* @brief Checks whether this actor uses the "chained send" optimization.
*/
inline bool chaining() const {
return m_chaining;
}
/**
* @brief Enables or disables chained send.
*/
inline void chaining(bool new_value) {
if (m_is_scheduled) {
m_chaining = new_value;
}
m_chaining = m_is_scheduled && new_value;
}
/**
* @brief Returns the last message that was dequeued
* from the actor's mailbox.
* @note Only set during callback invocation.
*/
inline any_tuple& last_dequeued() {
return m_last_dequeued;
}
/**
* @brief Returns the sender of the last dequeued message.
* @note Only set during callback invocation.
* @note Implicitly used by the function {@link cppa::reply}.
*/
inline actor_ptr& last_sender() {
return m_last_sender;
}
inline actor_ptr& chained_actor() {
return m_chained;
}
/**
* @brief Adds a unidirectional @p monitor to @p whom.
*
* @whom sends a "DOWN" message to this actor as part of its termination.
* @param whom The actor that should be monitored by this actor.
* @note Each call to @p monitor creates a new, independent monitor.
*/
void monitor(actor_ptr whom);
/**
* @brief Removes a monitor from @p whom.
* @param whom A monitored actor.
*/
void demonitor(actor_ptr whom);
// library-internal members and member functions that shall
// not appear in the documentation
# ifndef CPPA_DOCUMENTATION
local_actor(bool is_scheduled = false);
inline void send_message(channel* whom, any_tuple what) {
whom->enqueue(this, std::move(what));
......@@ -137,22 +171,20 @@ class local_actor : public actor {
}
}
/**
* @ingroup ActorManagement
* @brief Adds a unidirectional @p monitor to @p whom.
* @param whom The actor that should be monitored by this actor.
* @note Each call to @p monitor creates a new, independent monitor.
* @pre The calling actor receives a "DOWN" message from @p whom when
* it terminates.
*/
void monitor(actor_ptr whom);
inline actor_ptr& chained_actor() {
return m_chained;
}
/**
* @ingroup ActorManagement
* @brief Removes a monitor from @p whom.
* @param whom A monitored actor.
*/
void demonitor(actor_ptr whom);
protected:
bool m_chaining;
bool m_trap_exit;
bool m_is_scheduled;
actor_ptr m_chained;
actor_ptr m_last_sender;
any_tuple m_last_dequeued;
# endif // CPPA_DOCUMENTATION
};
......@@ -164,4 +196,4 @@ typedef intrusive_ptr<local_actor> local_actor_ptr;
} // namespace cppa
#endif // CONTEXT_HPP
#endif // CPPA_CONTEXT_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef MATCH_HPP
#define MATCH_HPP
#ifndef CPPA_MATCH_HPP
#define CPPA_MATCH_HPP
#include "cppa/any_tuple.hpp"
#include "cppa/partial_function.hpp"
......@@ -194,4 +194,4 @@ auto match_each(InputIterator first, InputIterator last, Projection proj)
} // namespace cppa
#endif // MATCH_HPP
#endif // CPPA_MATCH_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef MATCH_EXPR_HPP
#define MATCH_EXPR_HPP
#ifndef CPPA_MATCH_EXPR_HPP
#define CPPA_MATCH_EXPR_HPP
#include "cppa/option.hpp"
#include "cppa/pattern.hpp"
......@@ -44,6 +44,7 @@
#include "cppa/util/left_or_right.hpp"
#include "cppa/util/deduce_ref_type.hpp"
#include "cppa/detail/matches.hpp"
#include "cppa/detail/projection.hpp"
#include "cppa/detail/value_guard.hpp"
#include "cppa/detail/pseudo_tuple.hpp"
......@@ -912,4 +913,4 @@ partial_function mexpr_concat_convert(const Arg0& arg0, const Args&... args) {
} // namespace cppa
#endif // MATCH_EXPR_HPP
#endif // CPPA_MATCH_EXPR_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef OBJECT_HPP
#define OBJECT_HPP
#ifndef CPPA_OBJECT_HPP
#define CPPA_OBJECT_HPP
#include <string>
#include <typeinfo>
......@@ -197,4 +197,4 @@ const T& get(const object& obj) {
} // namespace cppa
#endif // OBJECT_HPP
#endif // CPPA_OBJECT_HPP
......@@ -28,8 +28,8 @@
\******************************************************************************/
#ifndef ON_HPP
#define ON_HPP
#ifndef CPPA_ON_HPP
#define CPPA_ON_HPP
#include <chrono>
#include <memory>
......@@ -51,7 +51,6 @@
#include "cppa/detail/boxed.hpp"
#include "cppa/detail/unboxed.hpp"
#include "cppa/detail/invokable.hpp"
#include "cppa/detail/value_guard.hpp"
#include "cppa/detail/ref_counted_impl.hpp"
#include "cppa/detail/implicit_conversions.hpp"
......@@ -409,4 +408,4 @@ constexpr detail::on_the_fly_rvalue_builder on_arg_match;
} // namespace cppa
#endif // ON_HPP
#endif // CPPA_ON_HPP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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