Boost logo

Boost Users :

Subject: Re: [Boost-users] boost msm - differed events
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2012-12-05 16:00:30


> Hi guys,
>
> I realized that I asked a very unclear question yesterday. I will try to
> reformulate :)
>
> Let's say I have 2 states, an Active state and an Idle state. If I receive
> some events in Active state I would like to defer them and execute them
> when I go back to Idle state.
>
> But when I go back to Idle State is there a way to chose which previously
> deferred event to process? or is there a way to prioritize them or even
> ignore few of them?
>
> Thank you!

Hi,

No, it was clear but I didn't get to answer yesterday.
In this case it's still simple. MSM will enqueue both events in the order
received. Say you get Ev1 then Ev2, then MSM will try to process them in
this order when you move back to Idle.
This is the easy part. It becomes harder if the second try to process also
defers. Then you could get some order inversion.
MSM uses the following algorithm:
- if deferred, add at the end of the queue
- after a transition is taken, we remove the first event from the queue and
try to process it.
- if it fails, we try the next one, etc. This means that this event, if
deferred, will be put back at then end of the queue and at the next try (a
successful transition) an event enqueued later on could be processed before
this one.

Note that this is the state from boost 1.51 and later. There were some bugs
earlier.

> But when I go back to Idle State is there a way to chose which previously
> deferred event to process?

Not directly. The only way I see is to add an internal transition which will
re-defer the chosen event.

>or is there a way to prioritize them

No, unless you use the previous trick.

>or even ignore few of them?

Yes if you add an internal transition to get rid of it. Then, as far as MSM
is concerned, the event has been processed.

HTH,
Christophe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net