Skip to content

Problems with ordering of chains of actions/effects #106

Open
@arximboldi

Description

@arximboldi

This is something that in the beginning I thought is a modeling problem, but I'm starting to find situations that make me wonder.

Example, we have action1, finish_action1, action2

  • action1 returns an effect that does something (maybe something as innocent as reading a time-stamp) and dispatches finish_action1, eg:
[](auto&& ctx) { ctx.dispatch(finish_action1{}); }
  • action2 does something, that can be dependent on state touched by finish_action1.
  • The user does:
dispatch(action_1{});
dispatch(action_2{});

The execution we get is however action_1, action_2, finish_action1, even if maybe one could expect (or require for correctness): action_1, finish_action1, action_2.

One solution would be to ensure that the effects from an action an all actions dispatched within it gets queued before any other actions in the queue. The implementation seems not trivial and can add a small overhead also in cases where it may be not necessary, since it requires keeping a nested queue for actions dispatched within the effect.

Considertions are:

  • Should we put this aspect of queueing in the event_loop interface?
  • Should we add a method dispatch_nested() to consider this special scenario?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions