Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

maintenance & documentation

  • Loading branch information...
commit 5b69972eb8acc24263ab83055d25968a1ac58e2d 1 parent f5767cc
Dominik Charousset Neverlord authored
Showing with 1,054 additions and 1,334 deletions.
  1. +2 −3 CMakeLists.txt
  2. +2 −2 benchmarks/actor_creation.cpp
  3. +2 −2 benchmarks/distributed.cpp
  4. +1 −1  benchmarks/mailbox_performance.cpp
  5. +6 −6 benchmarks/mixed_case.cpp
  6. +4 −7 cppa.files
  7. +3 −3 cppa/abstract_actor.hpp
  8. +4 −4 cppa/abstract_event_based_actor.hpp
  9. +3 −3 cppa/actor.hpp
  10. +5 −4 cppa/actor_proxy.hpp
  11. +3 −3 cppa/announce.hpp
  12. +3 −3 cppa/any_tuple.hpp
  13. +3 −3 cppa/anything.hpp
  14. +3 −3 cppa/atom.hpp
  15. +3 −3 cppa/attachable.hpp
  16. +3 −3 cppa/behavior.hpp
  17. +3 −3 cppa/binary_deserializer.hpp
  18. +3 −3 cppa/binary_serializer.hpp
  19. +3 −3 cppa/channel.hpp
  20. +44 −22 cppa/{detail/yielding_actor.hpp → context_switching_actor.hpp}
  21. +59 −47 cppa/cow_ptr.hpp
  22. +3 −3 cppa/cow_tuple.hpp
  23. +14 −6 cppa/cppa.hpp
  24. +3 −3 cppa/deserializer.hpp
  25. +3 −3 cppa/detail/abstract_scheduled_actor.hpp
  26. +3 −3 cppa/detail/abstract_tuple.hpp
  27. +3 −3 cppa/detail/actor_count.hpp
  28. +3 −3 cppa/detail/actor_proxy_cache.hpp
  29. +3 −3 cppa/detail/actor_registry.hpp
  30. +3 −3 cppa/detail/addressed_message.hpp
  31. +3 −3 cppa/detail/atom_val.hpp
  32. +3 −3 cppa/detail/boxed.hpp
  33. +3 −3 cppa/detail/buffer.hpp
  34. +4 −4 cppa/detail/channel.hpp
  35. +3 −3 cppa/detail/container_tuple_view.hpp
  36. +3 −3 cppa/detail/decorated_tuple.hpp
  37. +3 −3 cppa/detail/default_uniform_type_info_impl.hpp
  38. +3 −3 cppa/detail/demangle.hpp
  39. +3 −3 cppa/detail/disablable_delete.hpp
  40. +3 −3 cppa/detail/empty_tuple.hpp
  41. +3 −3 cppa/detail/filter_result.hpp
  42. +3 −3 cppa/detail/get_behavior.hpp
  43. +3 −3 cppa/detail/group_manager.hpp
  44. +3 −3 cppa/detail/implicit_conversions.hpp
  45. +0 −282 cppa/detail/invokable.hpp
  46. +3 −3 cppa/detail/list_member.hpp
  47. +3 −3 cppa/detail/mailman.hpp
  48. +3 −3 cppa/detail/map_member.hpp
  49. +3 −3 cppa/detail/matches.hpp
  50. +3 −3 cppa/detail/mock_scheduler.hpp
  51. +3 −3 cppa/detail/native_socket.hpp
  52. +3 −3 cppa/detail/nestable_receive_policy.hpp
  53. +3 −3 cppa/detail/network_manager.hpp
  54. +3 −3 cppa/detail/object_array.hpp
  55. +16 −16 cppa/detail/object_impl.hpp
  56. +3 −3 cppa/detail/pair_member.hpp
  57. +3 −3 cppa/detail/post_office.hpp
  58. +3 −3 cppa/detail/primitive_member.hpp
  59. +3 −3 cppa/detail/projection.hpp
  60. +3 −3 cppa/detail/pseudo_tuple.hpp
  61. +3 −3 cppa/detail/ptype_to_type.hpp
  62. +3 −6 cppa/detail/receive_loop_helper.hpp
  63. +3 −3 cppa/detail/recursive_queue_node.hpp
  64. +3 −3 cppa/detail/ref_counted_impl.hpp
  65. +4 −4 cppa/detail/scheduled_actor_dummy.hpp
  66. +3 −3 cppa/detail/serialize_tuple.hpp
  67. +3 −3 cppa/detail/singleton_manager.hpp
  68. +3 −3 cppa/detail/swap_bytes.hpp
  69. +3 −3 cppa/detail/tdata.hpp
  70. +3 −3 cppa/detail/thread_pool_scheduler.hpp
  71. +3 −3 cppa/detail/to_uniform_name.hpp
  72. +3 −3 cppa/detail/tuple_cast_impl.hpp
  73. +3 −3 cppa/detail/tuple_iterator.hpp
  74. +3 −3 cppa/detail/tuple_vals.hpp
  75. +3 −3 cppa/detail/tuple_view.hpp
  76. +3 −3 cppa/detail/type_to_ptype.hpp
  77. +33 −3 cppa/detail/types_array.hpp
  78. +3 −3 cppa/detail/unboxed.hpp
  79. +3 −3 cppa/detail/uniform_type_info_map.hpp
  80. +3 −3 cppa/detail/value_guard.hpp
  81. +3 −3 cppa/detail/yield_interface.hpp
  82. +3 −3 cppa/either.hpp
  83. +31 −4 cppa/event_based_actor.hpp
  84. +3 −3 cppa/event_based_actor_base.hpp
  85. +3 −3 cppa/exception.hpp
  86. +3 −3 cppa/exit_reason.hpp
  87. +3 −3 cppa/from_string.hpp
  88. +3 −3 cppa/fsm_actor.hpp
  89. +3 −3 cppa/get.hpp
  90. +3 −3 cppa/group.hpp
  91. +3 −3 cppa/guard_expr.hpp
  92. +7 −7 cppa/intrusive/forward_iterator.hpp
  93. +3 −3 cppa/intrusive/single_reader_queue.hpp
  94. +3 −3 cppa/intrusive/singly_linked_list.hpp
  95. +45 −95 cppa/intrusive_ptr.hpp
  96. +86 −54 cppa/local_actor.hpp
  97. +3 −3 cppa/match.hpp
  98. +4 −3 cppa/match_expr.hpp
  99. +3 −3 cppa/object.hpp
  100. +3 −4 cppa/on.hpp
  101. +3 −3 cppa/option.hpp
  102. +3 −4 cppa/partial_function.hpp
  103. +3 −3 cppa/pattern.hpp
  104. +3 −3 cppa/primitive_type.hpp
  105. +12 −58 cppa/primitive_variant.hpp
  106. +3 −3 cppa/process_information.hpp
  107. +3 −3 cppa/receive.hpp
  108. +3 −3 cppa/ref_counted.hpp
  109. +16 −15 cppa/scheduled_actor.hpp
  110. +3 −9 cppa/scheduler.hpp
  111. +3 −3 cppa/scheduling_hint.hpp
  112. +3 −3 cppa/self.hpp
  113. +3 −3 cppa/serializer.hpp
  114. +20 −11 cppa/stacked_event_based_actor.hpp
  115. +26 −15 cppa/{detail/converted_thread_context.hpp → thread_mapped_actor.hpp}
  116. +3 −3 cppa/to_string.hpp
  117. +3 −3 cppa/tpartial_function.hpp
  118. +3 −3 cppa/tuple_cast.hpp
  119. +3 −3 cppa/uniform_type_info.hpp
  120. +3 −3 cppa/util/abstract_uniform_type_info.hpp
  121. +3 −3 cppa/util/apply_args.hpp
  122. +3 −3 cppa/util/apply_tuple.hpp
  123. +33 −3 cppa/util/arg_match_t.hpp
  124. +3 −3 cppa/util/at.hpp
  125. +3 −3 cppa/util/comparable.hpp
  126. +3 −3 cppa/util/compare_tuples.hpp
  127. +3 −3 cppa/util/conjunction.hpp
  128. +3 −3 cppa/util/deduce_ref_type.hpp
  129. +3 −3 cppa/util/disjunction.hpp
  130. +3 −3 cppa/util/duration.hpp
  131. +3 −3 cppa/util/element_at.hpp
  132. +3 −3 cppa/util/fiber.hpp
  133. +3 −3 cppa/util/fixed_vector.hpp
  134. +3 −3 cppa/util/if_else.hpp
  135. +3 −3 cppa/util/is_array_of.hpp
  136. +33 −3 cppa/util/is_builtin.hpp
  137. +3 −3 cppa/util/is_comparable.hpp
  138. +3 −3 cppa/util/is_forward_iterator.hpp
  139. +3 −3 cppa/util/is_iterable.hpp
  140. +3 −3 cppa/util/is_legal_tuple_type.hpp
  141. +3 −3 cppa/util/is_manipulator.hpp
  142. +3 −3 cppa/util/is_mutable_ref.hpp
  143. +3 −3 cppa/util/is_primitive.hpp
  144. +3 −3 cppa/util/left_or_right.hpp
  145. +3 −3 cppa/util/producer_consumer_list.hpp
  146. +0 −40 cppa/util/projection.hpp
  147. +3 −3 cppa/util/pt_dispatch.hpp
  148. +3 −3 cppa/util/pt_token.hpp
  149. +3 −3 cppa/util/purge_refs.hpp
  150. +3 −3 cppa/util/replace_type.hpp
  151. +3 −3 cppa/util/ripemd_160.hpp
  152. +3 −3 cppa/util/rm_option.hpp
  153. +3 −3 cppa/util/rm_ref.hpp
  154. +3 −3 cppa/util/shared_lock_guard.hpp
  155. +3 −3 cppa/util/shared_spinlock.hpp
  156. +3 −3 cppa/util/static_foreach.hpp
  157. +3 −3 cppa/util/tbind.hpp
  158. +3 −3 cppa/util/type_list.hpp
  159. +3 −3 cppa/util/type_pair.hpp
  160. +3 −3 cppa/util/upgrade_lock_guard.hpp
  161. +3 −3 cppa/util/void_type.hpp
  162. +3 −3 cppa/util/wrapped.hpp
  163. +1 −1  examples/math_actor_example.cpp
  164. +5 −6 src/abstract_event_based_actor.cpp
  165. +29 −27 src/{yielding_actor.cpp → context_switching_actor.cpp}
  166. +0 −46 src/invokable.cpp
  167. +2 −2 src/mock_scheduler.cpp
  168. +4 −3 src/network_manager.cpp
  169. +1 −3 src/partial_function.cpp
  170. +1 −1  src/primitive_variant.cpp
  171. +5 −8 src/scheduled_actor.cpp
  172. +8 −13 src/scheduled_actor_dummy.cpp
  173. +3 −5 src/scheduler.cpp
  174. +3 −3 src/self.cpp
  175. +25 −13 src/singleton_manager.cpp
  176. +0 −4 src/stacked_event_based_actor.cpp
  177. +13 −13 src/{converted_thread_context.cpp → thread_mapped_actor.cpp}
  178. +27 −36 src/thread_pool_scheduler.cpp
  179. +2 −3 src/uniform_type_info.cpp
  180. +1 −1  unit_testing/ping_pong.cpp
  181. +0 −1  unit_testing/test__pattern.cpp
  182. +6 −7 unit_testing/test__primitive_variant.cpp
  183. +3 −3 unit_testing/test__spawn.cpp
  184. +0 −1  unit_testing/test__tuple.cpp
5 CMakeLists.txt
View
@@ -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/)
4 benchmarks/actor_creation.cpp
View
@@ -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();
}
);
}
4 benchmarks/distributed.cpp
View
@@ -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;
2  benchmarks/mailbox_performance.cpp
View
@@ -53,7 +53,7 @@ struct fsm_receiver : fsm_actor<fsm_receiver> {
on(atom("msg")) >> [=]() {
++m_value;
if (m_value == max) {
- quit_normal();
+ quit();
}
}
);
12 benchmarks/mixed_case.cpp
View
@@ -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();
}
);
}
11 cppa.files
View
@@ -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
6 cppa/abstract_actor.hpp
View
@@ -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
8 cppa/abstract_event_based_actor.hpp
View
@@ -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
6 cppa/actor.hpp
View
@@ -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
9 cppa/actor_proxy.hpp
View
@@ -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
6 cppa/announce.hpp
View
@@ -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
6 cppa/any_tuple.hpp
View
@@ -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
6 cppa/anything.hpp
View
@@ -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
6 cppa/atom.hpp
View
@@ -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
6 cppa/attachable.hpp
View
@@ -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
6 cppa/behavior.hpp
View
@@ -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
6 cppa/binary_deserializer.hpp
View
@@ -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
6 cppa/binary_serializer.hpp
View
@@ -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
6 cppa/channel.hpp
View
@@ -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
66 cppa/detail/yielding_actor.hpp → cppa/context_switching_actor.hpp
View
@@ -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
106 cppa/cow_ptr.hpp
View
@@ -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
6 cppa/cow_tuple.hpp
View
@@ -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
20 cppa/cppa.hpp
View
@@ -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
*
6 cppa/deserializer.hpp
View
@@ -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
6 cppa/detail/abstract_scheduled_actor.hpp
View
@@ -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
6 cppa/detail/abstract_tuple.hpp
View
@@ -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
6 cppa/detail/actor_count.hpp
View
@@ -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
6 cppa/detail/actor_proxy_cache.hpp
View
@@ -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
6 cppa/detail/actor_registry.hpp
View
@@ -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
6 cppa/detail/addressed_message.hpp
View
@@ -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
6 cppa/detail/atom_val.hpp
View
@@ -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
6 cppa/detail/boxed.hpp
View
@@ -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
6 cppa/detail/buffer.hpp
View
@@ -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
8 cppa/detail/channel.hpp
View
@@ -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
6 cppa/detail/container_tuple_view.hpp
View
@@ -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
6 cppa/detail/decorated_tuple.hpp
View
@@ -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
6 cppa/detail/default_uniform_type_info_impl.hpp
View
@@ -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
6 cppa/detail/demangle.hpp
View
@@ -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
6 cppa/detail/disablable_delete.hpp
View
@@ -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
6 cppa/detail/empty_tuple.hpp
View
@@ -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
6 cppa/detail/filter_result.hpp
View
@@ -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
6 cppa/detail/get_behavior.hpp
View
@@ -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
6 cppa/detail/group_manager.hpp
View
@@ -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
6 cppa/detail/implicit_conversions.hpp
View
@@ -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
282 cppa/detail/invokable.hpp
View
@@ -1,282 +0,0 @@
-/******************************************************************************\
- * ___ __ *
- * /\_ \ __/\ \ *
- * \//\ \ /\_\ \ \____ ___ _____ _____ __ *
- * \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
- * \_\ \_\ \ \ \ \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
6 cppa/detail/list_member.hpp
View
@@ -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
6 cppa/detail/mailman.hpp
View
@@ -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
6 cppa/detail/map_member.hpp
View
@@ -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
6 cppa/detail/matches.hpp
View
@@ -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
6 cppa/detail/mock_scheduler.hpp
View
@@ -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
6 cppa/detail/native_socket.hpp
View
@@ -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
6 cppa/detail/nestable_receive_policy.hpp
View
@@ -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
6 cppa/detail/network_manager.hpp
View
@@ -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
6 cppa/detail/object_array.hpp
View
@@ -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
32 cppa/detail/object_impl.hpp
View
@@ -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
6 cppa/detail/pair_member.hpp
View
@@ -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
6 cppa/detail/post_office.hpp
View
@@ -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
6 cppa/detail/primitive_member.hpp
View
@@ -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
6 cppa/detail/projection.hpp
View
@@ -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
6 cppa/detail/pseudo_tuple.hpp
View
@@ -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
6 cppa/detail/ptype_to_type.hpp
View
@@ -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
9 cppa/detail/receive_loop_helper.hpp
View
@@ -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
6 cppa/detail/recursive_queue_node.hpp
View
@@ -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
6 cppa/detail/ref_counted_impl.hpp
View
@@ -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
8 cppa/detail/scheduled_actor_dummy.hpp
View
@@ -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
6 cppa/detail/serialize_tuple.hpp
View
@@ -28,8 +28,8 @@
\******************************************************************************/