Hi
I am looking for any articles anyone may know of on developing a finite
state machine in a gui application?
Basically what I have is a fairly complex gui which needs to go through
several (3 - 7?) states. Complex algorithms are running as their own
separate code blocks operating on class-level data structures, the
completion of the processing of one set of data takes the application from
one 'state' to another. Once the last operation is complete, some user
activity will probably have occurred on the user interface that makes it
'dirty' and means the first operation has to start again, to cycle the
transition of repopulating the data structures to update them.
I've decided to go down the multithreading road, because the operations take
too long (a few whole seconds) for them to execute in the primary thread of
the user interface as they block it up, but there probably IS time for them
all to run in time to 'keep up' with the user entering data as they cannot
enter a lot of data incessantly fast all the time (or probably won't) - as
the time they have to lock some actual elements on the interface is
negligible compared to the total time they will take to run.
What's more, there are some cases which will be identified where the first
process can start again before the last one of the previous cycle has
completely finished, enabling a multithreading scenario to take advantage of
this.
What's the best way of accomplishing this? I'm trying to work on a suitable
class structure.
Klueless - 04 Jun 2004 05:54 GMT
> I've decided to go down the multithreading road, because the operations take
> too long (a few whole seconds)
The simplest approach is to have one GUI thread (the main thread)
and one worker thread (background, non-GUI). The worker thread
will own the FSM. Arrange user actions on the GUI to cause the GUI
thread to post messages to the worker thread which will act on them when
finished with any preexisting work.
Russell Hind - 04 Jun 2004 08:27 GMT
> Hi
> I am looking for any articles anyone may know of on developing a finite
> state machine in a gui application?
You could take a look at the fsm library in the boost sandbox.
Documentation index is
http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost-sandbox/boost-sandbox/lib
s/fsm/doc/index.html
and a tutorial at
http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost-sandbox/boost-sandbox/lib
s/fsm/doc/tutorial.html
The document and code are in
http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/libs/fsm/
http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/fsm/
There is quite a lot of discussion going on about this library at the
moment on the boost libs. I haven't been able to try it myself as it
doesn't work with bcc32 which is my current compiler, but I am
interested in it because we do implement a lot of state machines here.
You could get more help with it from the boost newsgroups if interested.
Cheers
Russell