Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-05-24 22:26:38

Andreas Huber <ah2003_at_[hidden]> writes:

> David Abrahams <dave <at>> writes:
>> > I'm not only saying this because an active state happens to be an
>> > object in boost::fsm. State machines frequently acquire resources
>> > in entry actions and dispose of them in exit actions. Those
>> > resources would simply be leaked if there's no guarantee that exit
>> > actions are called under all non-fatal error situations.
>> It seems reasonable that well-designed state objects should also
>> deallocate any resources they own in their destructors. It doesn't
>> neccessarily seem reasonable as a consequence to force all exit
>> actions into the state's destructor.
> Are you proposing that an active state should still be represented by an
> object,

I don't have enough knowledge of the FSM domain to say whether that's
a good design or not; I have to trust you that it makes sense to have
a correspondence between states and distinct types whose instances'
lifetimes correspond to the time spent in the state.

> which acquires resources and executes entry actions in its
> constructor, releases resources in its destructor but executes exit
> actions in a separate function, which is called just before
> destructing the state object?

Yes, that's basically what I was saying.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at