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

Remove `discard_behavior`

parent 0f088db7
......@@ -22,28 +22,12 @@
namespace caf {
template <bool DiscardBehavior>
struct behavior_policy {
static constexpr bool discard_old = DiscardBehavior;
struct keep_behavior_t {
constexpr keep_behavior_t() {
// 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
* keep the current behavior available.
......
......@@ -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); }
template <bool Discard>
void become(behavior_policy<Discard>, behavior_type bhvr) {
do_become(std::move(bhvr), Discard);
inline void become(const keep_behavior_t&, behavior_type bhvr) {
do_become(std::move(bhvr), false);
}
template <class T, class... Ts>
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
become(T&& arg, Ts&&... args) {
do_become(
......@@ -74,9 +73,9 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> {
true);
}
template <bool Discard, class... Ts>
void become(behavior_policy<Discard>, Ts&&... args) {
do_become(behavior_type{std::forward<Ts>(args)...}, Discard);
template <class... Ts>
void become(const keep_behavior_t&, Ts&&... args) {
do_become(behavior_type{std::forward<Ts>(args)...}, false);
}
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