Commit ca6df069 authored by neverlord's avatar neverlord Committed by Dominik Charousset

Remove `discard_behavior`

parent 0f088db7
...@@ -22,28 +22,12 @@ ...@@ -22,28 +22,12 @@
namespace caf { namespace caf {
template <bool DiscardBehavior> struct keep_behavior_t {
struct behavior_policy { constexpr keep_behavior_t() {
static constexpr bool discard_old = DiscardBehavior; // nop
}
}; };
template <class T>
struct is_behavior_policy : std::false_type {};
template <bool DiscardBehavior>
struct is_behavior_policy<behavior_policy<DiscardBehavior>> : std::true_type {};
using keep_behavior_t = behavior_policy<false>;
using discard_behavior_t = behavior_policy<true>;
/**
* Policy tag that causes {@link event_based_actor::become} to
* discard the current behavior.
* @relates local_actor
*/
constexpr discard_behavior_t discard_behavior = discard_behavior_t{};
/** /**
* Policy tag that causes {@link event_based_actor::become} to * Policy tag that causes {@link event_based_actor::become} to
* keep the current behavior available. * keep the current behavior available.
......
...@@ -59,14 +59,13 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> { ...@@ -59,14 +59,13 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> {
void become(behavior_type bhvr) { do_become(std::move(bhvr), true); } void become(behavior_type bhvr) { do_become(std::move(bhvr), true); }
template <bool Discard> inline void become(const keep_behavior_t&, behavior_type bhvr) {
void become(behavior_policy<Discard>, behavior_type bhvr) { do_become(std::move(bhvr), false);
do_become(std::move(bhvr), Discard);
} }
template <class T, class... Ts> template <class T, class... Ts>
inline typename std::enable_if< inline typename std::enable_if<
!is_behavior_policy<typename std::decay<T>::type>::value, !std::is_same<keep_behavior_t, typename std::decay<T>::type>::value,
void>::type void>::type
become(T&& arg, Ts&&... args) { become(T&& arg, Ts&&... args) {
do_become( do_become(
...@@ -74,9 +73,9 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> { ...@@ -74,9 +73,9 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> {
true); true);
} }
template <bool Discard, class... Ts> template <class... Ts>
void become(behavior_policy<Discard>, Ts&&... args) { void become(const keep_behavior_t&, Ts&&... args) {
do_become(behavior_type{std::forward<Ts>(args)...}, Discard); do_become(behavior_type{std::forward<Ts>(args)...}, false);
} }
inline void unbecome() { m_bhvr_stack.pop_async_back(); } inline void unbecome() { m_bhvr_stack.pop_async_back(); }
......
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