views:

465

answers:

1

In our project we have UI and logic (which may be represented as a state machine). Transitions between some steps in this step machine are long (IO-bound). We don't want to steal our UI thread for all the time the transition is in progress. Therefore we are looking for a way to perform this transitions in a separate thread and then update the UI when the transition finishes.

I currently evaluate the boost statechart library as one of the options to implement such a logic and I'd like to ask what's the proper way of implementing such a long-time transitions functionality using it?

Thanks.

+1  A: 

Transitions between states should be triggered by an event, not a long operation.

If you have logic which has any long operations whatsoever, it would be better to put the UI into its own thread, otherwise you'll be unresponsive.

You can always have two independent state machines in their own threads, and then use inter-thread communications for each to trigger one another. Message-passing is probably the most reliable approach. (boost::interprocess::message_queue may be overkill but it would work)

Jason S