Skip to content

issue with double deferring #416

@FE-EnricoSartori

Description

@FE-EnricoSartori

In the following example, a state machine containing 3 initial states is proposed. All these states should transit to the exit state when the event e1 is received. In order to propagate such event to all the initial states, it is deferred two times. The expectation is not satisfied since only the first defer works properly.

Example:

#include <boost/sml.hpp>
#include <cassert>
#include <deque>
#include <queue>
#include <iostream>

namespace sml = boost::sml;

namespace {

struct e1 {};

struct defer_and_process {
  auto operator()() const noexcept {
    using namespace sml;
    return make_transition_table(
       *"s1"_s  + event<e1> / defer = X
      ,*"s2"_s  + event<e1> / defer = X
      ,*"s3"_s  + event<e1> = X
    );
  }
};
}  // namespace

int main() {

  using namespace sml;
  sm<defer_and_process, sml::defer_queue<std::deque>, sml::process_queue<std::queue>> sm;

  assert(sm.is("s1"_s, "s2"_s, "s3"_s));

  sm.process_event(e1{});

  std::cout << sm.is(X,X,"s3"_s) << std::endl;  // TRUE - Expected to be FALSE
  std::cout << sm.is(X,X,X) << std::endl;       // FALSE - Expected to be TRUE
}

Is this the correct behavior? How can I implement the expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions