You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code contains two state machines which use deferred tasks and orthogonal regions. The two state machines are identical except for the order in which the orthogonal regions are defined. Deferred tasks only work in the version that contains them in the first orthogonal region.
Specifications
Version: 1.1.9
Platform: Any
Code
For reference, here is the code that reproduces the problem (in the compiler explorer):
#include <cstdio>
#include <cassert>
#include <deque>
#include <https://raw.githubusercontent.com/boost-experimental/sml/master/include/boost/sml.hpp>
namespace sml = boost::sml;
struct sm_logger
{
template <class SM, class TEvent>
void log_process_event(const TEvent&)
{
printf("[%s][process_event] %s\n", sml::aux::get_type_name<SM>(), sml::aux::get_type_name<TEvent>());
}
template <class SM, class TSrcState, class TDstState>
void log_state_change(const TSrcState& src, const TDstState& dst)
{
printf("[%s][transition] %s -> %s\n", sml::aux::get_type_name<SM>(), src.c_str(), dst.c_str());
}
};
struct e1 {};
struct e2 {};
struct e3 {};
struct dummy1 {};
struct dummy2 {};
struct defer_chain_first_region
{
auto operator()() const noexcept
{
using namespace sml;
return make_transition_table(
* "s0"_s + event<e1> / defer
,"s0"_s + event<e2> = "s1"_s
,"s1"_s + event<e1> = "s0"_s
,* "dummy1"_s + event<dummy1> = X
,* "dummy2"_s + event<dummy2> = X
);
}
};
// identical to previous state machine except that first and second regions swapped
struct defer_chain_second_region
{
auto operator()() const noexcept
{
using namespace sml;
return make_transition_table(
* "dummy1"_s + event<dummy1> = X
,* "s0"_s + event<e1> / defer
,"s0"_s + event<e2> = "s1"_s
,"s1"_s + event<e1> = "s0"_s
,* "dummy2"_s + event<dummy2> = X
);
}
};
int main()
{
using namespace sml;
printf("Test defer in first region\n");
sm_logger logger;
sml::sm<defer_chain_first_region, sml::defer_queue<std::deque>
, sml::logger<sm_logger>
> sm_first{logger};
sm_first.process_event(e1{});
sm_first.process_event(e2{});
sm_first.process_event(e3{});
assert(sm_first.is("s0"_s));
if (!sm_first.is("s0"_s))
{
printf("*** defer not processed correctly - final state transition missing! ***\n");
}
printf("\nTest defer in second region\n");
sml::sm<defer_chain_second_region, sml::defer_queue<std::deque>
, sml::logger<sm_logger>
> sm_second{logger};
sm_second.process_event(e1{});
sm_second.process_event(e2{});
sm_second.process_event(e3{});
assert(sm_second.is("s0"_s));
if (!sm_second.is("s0"_s))
{
printf("*** defer not processed correctly - final state transition missing! ***\n");
}
}
The text was updated successfully, but these errors were encountered:
Expected Behavior
Deferred events should be reprocessed when transitioning into a new state
Actual Behavior
If the state is not in the first orthogonal region of the state machine, the deferred event is not processed
Steps to Reproduce the Problem
Specifications
Code
For reference, here is the code that reproduces the problem (in the compiler explorer):
The text was updated successfully, but these errors were encountered: