[clug-progsig] Keeping Status

Shawn sgrover at open2space.com
Thu Feb 8 05:12:51 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This weeks challenge... :)

I have a number of objects, some of which will work asynchronously, and
almost all of them can have different states at any given time while
processing is happening.  I need to be able to display the "current"
status, but the asynch and multi state issues are causing grief.

So, I'm looking for ideas.

The model is something like this:

objectA
objectA.arrayB (contains objectB's)

objectB
objectB.objectC
objectB.arrayD (contains objectD's)

objectC
objectC.arrayE

objectD
objectD.arrayE (yes, same type of object as objectC's array)

So, when objectA loads, it get's it's list of objectBs.
Then each objectB is told to get it's data, and so on.

Each object is operating asynchronously.  So, I can't just set a global
status flag.  (objectX might still be loading, but objectY may have
cleared the status, which is not indicative of what's really happening
at that point in time).

I've tried to give each object a "state" queue, which is a simple array
of messages and timestamps.  Then objectA displays the latest "state" as
it's status, and each time a state is changed, it calls the routine to
redetermine the current state.  Unfortunately this isn't working well.

I thought about using an observer pattern, but am not quite sure that's
the right answer here, and it could have substantial impact on the code.
 (seeing as it wasn't written with an explicit pattern approach)

I've been trying to resolve this for the past 4 hours, and I can't help
but fell my approach is just wrong.  So I'm looking for alternatives.
Any suggestions are appreciated.

Shawn

(NOTE:  the above problem has been highly simplified for the purpose of
posting here.  In some ways it's not quite as complex, and in other ways
it's MUCH MUCH more complex... :)





-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFyyHTMia5XCIAQC8RAi6hAKCMNq6KGeQbNQxo7mk3qGCAIRTN1wCfYMTK
8trzuMuN2IXPE10zLgQsBXc=
=GjXP
-----END PGP SIGNATURE-----




More information about the clug-progsig mailing list