Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Call a state activity #189

Open
Lecrapouille opened this issue Dec 19, 2023 · 0 comments
Open

[FEATURE] Call a state activity #189

Lecrapouille opened this issue Dec 19, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Lecrapouille
Copy link

Problem

How to run a state activity when I'm on a given state ?

An action is instantaneous: it does not consume time (contrary to the activity). The activity can be seen as a thread that is preempted by any external events the state reacts to. https://cs.emis.de/LNI/Proceedings/Proceedings07/TowardEfficCode_3.pdf

struct MyState {
  MyState(hsm::sm<MyFSM>& fsm)
    : m_sfm(fsm)
   {}

  void tickActivity()
  {
      // do_something not blocking too much
      // Allow m_fsm.process_event(EventXXX {});
  }

  sm::sm<MyFSM>& m_fsm;
};

main()
{
  hsm::sm<MyFSM> fsm;
  while (true)
  {
      fsm.tickActivity(); // Call the current state tickActivity()
      pause(x_ms);
  }
}
@Lecrapouille Lecrapouille added the enhancement New feature or request label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant