|
Boost Users : |
Subject: Re: [Boost-users] Boost MSM - Ways to send info out from state machine to outside world
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2011-09-10 15:57:13
> Christophe Henry wrote:
>>
>>
>>> 2. Have following transition:
>>> Row < state_waiting, none, state_waiting, none, Gc_always_false>
>>> where guard condition Gc_always_false returns false, prohibiting the
>>> transition but still keeping the state machine alive.
>>>
>>> Can you please tell me if the 2nd option is correct and if there is a
>>> better
>>> way to sit idle in one state and keep the machine alive.
>>
>> If you want to keep your processor busy, sure, but I won't recommend it
>> ;-)
>> Seriously, a state machine is event-triggered and does nothing until a
>> next
>> event is fired. It's a purely reactive system.
>> What are you trying to achieve?
>>
>
> I was under the impression that if the FSM runs out of events it dies and
> so
> one needs to keep feeding it events (be it none()) to keep the machine
> alive. In my case, I can think of at least two scenarios where my machine
> will be sitting idle: 1. While setting up connection, till it gets
> response
> from the remote device 2.After sending its share of data, till it receives
> new lot from the controller. Since I was under the impression that I have
> to
> keep calling an event to keep the machine alive, I was looking for a
> mechanism that will let me call an event but /not/ change the state and
> /not/ keep reentering the same state again and again, causing seg fault.
>>From what you are saying, I will assume that if the state machine enters
> waiting state (or any other state for that matter) and no event occurs, it
> will stay in the same state forever. Also, I will assume that the state
> machine will die whenever it goes out of scope (if its a stack variable)
> or
> is explicitly deleted (if created on heap).
The state machine will die only when destroyed (by going out of scope or
being deleted). Until it happens, it does nothing.
The only time it does something is when you process an event.
> Christophe Henry wrote:
>>
>> True, there are state machine libraries running constantly in a thread,
>> but this eats your
>> cycles faster than a wolf a herd of sheeps and causes more race
>> conditions
>> than the upcoming Oktoberfest will produce drunken tourists sleeping on
>> the
>> pavement on my way home ;-)
>>
> Btw those analogies were hilarious!
>
> Thanks for the help!
:)
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