<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hello Avery,<BR>
<BR>> On 15/02/2008, Robert Rawlins <robert_rawlins@hotmail.com> wrote:<BR>> > I do startProcess()<BR>> > startProcess() calls back with processStarted()<BR>> > processStarted() then starts soSomthing()<BR>> > doSomthing calls back with somthingDone()<BR>> > somethingDone() then started doAnotherThing()<BR>> > doAnotherThing() calls back and starts doTheLastThing()<BR>> ><BR>> > Do you see what I mean? a link of function calls and callbacks which cause<BR>> > a chain reaction and progress the particular element of the application to<BR>> > go through its states.<BR>> > [...]<BR>> > After looking around this morning it would seem that a<BR>> > Finite State Machine is designed to manage this kind of process for me, is<BR>> > that correct?<BR>> <BR>> Actually, the process you described is already a finite state machine<BR>> :) FSMs are really just a way of thinking about programs that go<BR>> through a series of states. The math doesn't particularly help you<BR>> implement one.<BR>> <BR>> I think what you might want are "continuations" or "coroutines." In<BR>> C++, the WvStreams library contains a class called WvCont that does it<BR>> very nicely: http://alumnit.ca/wvstreams/docs/wvcont_8h-source.html<BR>> <BR>> If you're using .net (mono / C#), I wrote a simple implementation of<BR>> the same thing using (weirdly enough) .net iterators:<BR>> http://www.advogato.org/person/apenwarr/diary/358.html<BR>> <BR>> You can do something similar with raw setjmp/longjmp, but I'm not sure<BR>> you want to get into that :)<BR>> <BR>> Another option is to use blocking dbus method calls in a thread,<BR>> although threads introduce their own set of problems.<BR>> <BR>> Have fun,<BR>> <BR>> Avery<BR>
<BR>
Thanks for the thorough explanation :-) This is all a new and alien concept to me, I come from a background in web development so the hole concept of automated applications and event driven models is very new to me.<BR>
<BR>
I see what you mean about my current process being an Finite State Machine of sorts, I've just been looking around at a few examples of creating an FSM class which you can implement into the application which contains a table of transactions and states and their associated methods. I cant really see any real benefit to me implementing one as the application seems to run just peachy as is, I was just interested to see how it might implement from a technical learning exercise point of view.<BR><BR>
Thanks for the suggestions Avery, I apprecaite it,<BR>
<BR>
Robert<BR><br /><hr />Sounds like? How many syllables? <a href='http://www.searchcharades.com' target='_new'>Guess and win prizes with Search Charades!</a></body>
</html>